HP Forums
HP 50g: Mantissa of an Extended Real - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: General Forum (/forum-4.html)
+--- Thread: HP 50g: Mantissa of an Extended Real (/thread-9246.html)



HP 50g: Mantissa of an Extended Real - Gerald H - 10-07-2017 12:23 PM

Does anyone have a programme to get the mantissa of an extended real on the 50g - the shorter the better?


RE: HP 50g: Mantissa of an Extended Real - Gerald H - 10-07-2017 03:24 PM

Here is my attempt at a solution, but I fear the programme is too large & slow:

Code:
::
  CK1&Dispatch
  BINT63
  ::
    DUP
    %%0=
    ?SEMI
    %%ABS
    %%10
    OVER
    DO>STR
    DUP
    CHR_E
    BINT1
    POSCHR
    #1+LAST$
    FPTR2 ^S>Z
    FPTR2 ^Z2%%
    %%^
    %%/
  ;
;



RE: HP 50g: Mantissa of an Extended Real - DavidM - 10-07-2017 04:48 PM

(10-07-2017 03:24 PM)Gerald H Wrote:  Here is my attempt at a solution, but I fear the programme is too large & slow:
...

This is smaller and faster, but there's probably still a better way:
Code:
::
   CK1&Dispatch
   BINT63 ::
      TOTEMPOB
      CODEM
         A=DAT1 A
         AD0EX
         D0+5
         C=0 A
         DAT0=C A
         D0+15
         D0+5
         DAT0=C P
         AD0EX
         RPL
      ENDCODE
   ;
;



RE: HP 50g: Mantissa of an Extended Real - Gerald H - 10-07-2017 06:19 PM

Excellent, DavidM!

Much faster than any programme I have seen to find extended mantissa.

Deals with %%0 & negative powers correctly, only critique is negative numbers remain negative.


RE: HP 50g: Mantissa of an Extended Real - DavidM - 10-07-2017 06:33 PM

(10-07-2017 06:19 PM)Gerald H Wrote:  ...negative numbers remain negative.

I'll admit that I didn't test this out extensively, but I did try at least one negative number and the sign was changed to positive (as it should have been, due to the DAT0=C P step). What did you test with this that didn't result in a positive mantissa?


RE: HP 50g: Mantissa of an Extended Real - Gerald H - 10-07-2017 07:38 PM

Various negatives,eg %% -7.7E1, %% -1E0, %% -1E66, the negative sign is consistently retained.

I haven't found one negative number that shows a positive mantissa.


RE: HP 50g: Mantissa of an Extended Real - Gerald H - 10-07-2017 07:46 PM

Sorry, I must have erred in copying the instructions, on recompiling the negatives are dealt with correctly.


RE: HP 50g: Mantissa of an Extended Real - DavidM - 10-07-2017 07:55 PM

(10-07-2017 07:46 PM)Gerald H Wrote:  Sorry, I must have erred in copying the instructions, on recompiling the negatives are dealt with correctly.

No problem. You had me really scratching my head for a while there, though.

I should have included the checksum/byte count as a safeguard.

Here's the commented code, in case anyone is interested. I did swap two lines in this one to make the flow more consistent (it doesn't make a difference in the result, of course).

Checksum: FAECh
Bytes: 41
Code:
::
   CK1&Dispatch            ( must have at least 1 argument on stack )
   BINT63 ::               ( argument type must be extended real )
      TOTEMPOB             ( make a duplicate of the extended real for the result )
      CODEM                % start MASD code block
         A=DAT1 A          % A.A -> SL1 object (the result)
         AD0EX             % save D0 in A.A, D0 now points to result object
         D0+5              % advance D0 past prologue
         C=0 A             % C.A = 0
         DAT0=C A          % zero-out exponent field
         D0+5              % advance D0 past exponent field
         D0+15             % advance D0 past mantissa field
         DAT0=C P          % zero-out sign field
         AD0EX             % restore original D0 from A.A
         RPL               % return to RPL
      ENDCODE              ( end MASD code block )
   ;
;



RE: HP 50g: Mantissa of an Extended Real - Arno K - 10-07-2017 09:36 PM

Quite informative, thank you.
Arno


RE: HP 50g: Mantissa of an Extended Real - Gerald H - 10-08-2017 06:42 AM

Some background:

You may remember a library for the 48G

http://www.hpcalc.org/details/1243

called EXMATH which took control of screen & keyboard & created an RPN calculator working with exponents up to 49999.

I have updated the library to work on the 49G ver 1.19-6 & 2.10-7 & on the 50g ver 2.10-7, adding some extra functions & trying to improve performance.

I am confident that my own programming is not optimal & am very grateful for assistance.


RE: HP 50g: Mantissa of an Extended Real - Arno K - 10-08-2017 07:43 AM

Helping with things like that is for the time being way beyond my abilities (and the amount of time I can invest), I am refreshing my URPL which hadn't been used for mor than 10 years, I have recently started looking into the available SRPL books and I like writing little programs. So I usually have a close look at your programs which always seem to be very effective.
Arno


RE: HP 50g: Mantissa of an Extended Real - Gerald H - 10-09-2017 10:17 AM

The annotations are very welcome, DavidM, as I am fearful of writing any assembly language code & regard its effect as magical.

Writing programmes in User & Sys RPL requires much less initiation, really just a mechanized form of algebra.

I think, Arno, that the change from User to Sys is not so big a step & the gain in speed is well worth the effort. I look forward to you writing some interesting programmes.


RE: HP 50g: Mantissa of an Extended Real - DavidM - 10-09-2017 02:45 PM

(10-09-2017 10:17 AM)Gerald H Wrote:  The annotations are very welcome, DavidM, as I am fearful of writing any assembly language code & regard its effect as magical.

I think of writing Saturn code in a similar fashion to building furniture out of Lego blocks. It can be done, but you better have both a good reason and a good plan or you'll go insane before you finish it. Smile

Although I rarely choose assembly solutions as a first approach, this one seemed like a perfect fit -- simply setting the exponent and sign fields to 0 was all that was needed, and I knew that would be fairly easy (and fast) in assembly.

(10-09-2017 10:17 AM)Gerald H Wrote:  I think, Arno, that the change from User to Sys is not so big a step & the gain in speed is well worth the effort. I look forward to you writing some interesting programmes.

I agree!


RE: HP 50g: Mantissa of an Extended Real - franz.b - 10-10-2017 06:32 PM

(10-08-2017 06:42 AM)Gerald H Wrote:  ...

I have updated the library to work on the 49G ver 1.19-6 & 2.10-7 & on the 50g ver 2.10-7, adding some extra functions & trying to improve performance.
...

where can we find it? Smile


RE: HP 50g: Mantissa of an Extended Real - Gerald H - 10-10-2017 06:39 PM

Nowhere as yet, should however probably shortly appear at

http://www.hpcalc.org/


RE: HP 50g: Mantissa of an Extended Real - Gerald H - 10-13-2017 05:41 AM

(10-10-2017 06:32 PM)franz.b Wrote:  
(10-08-2017 06:42 AM)Gerald H Wrote:  ...

I have updated the library to work on the 49G ver 1.19-6 & 2.10-7 & on the 50g ver 2.10-7, adding some extra functions & trying to improve performance.
...

where can we find it? Smile

Now available at

http://www.hpcalc.org/details/8702


RE: HP 50g: Mantissa of an Extended Real - franz.b - 10-13-2017 06:52 AM

(10-13-2017 05:41 AM)Gerald H Wrote:  
(10-10-2017 06:32 PM)franz.b Wrote:  where can we find it? Smile

Now available at

http://www.hpcalc.org/details/8702

thank you very much! I saw it yesterday in hpcalc news and today in hpforums posts!