Post Reply 
HP 50g: Mantissa of an Extended Real
10-07-2017, 12:23 PM
Post: #1
HP 50g: Mantissa of an Extended Real
Does anyone have a programme to get the mantissa of an extended real on the 50g - the shorter the better?
Find all posts by this user
Quote this message in a reply
10-07-2017, 03:24 PM
Post: #2
RE: HP 50g: Mantissa of an Extended Real
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%%
    %%^
    %%/
  ;
;
Find all posts by this user
Quote this message in a reply
10-07-2017, 04:48 PM
Post: #3
RE: HP 50g: Mantissa of an Extended Real
(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
   ;
;
Find all posts by this user
Quote this message in a reply
10-07-2017, 06:19 PM (This post was last modified: 10-07-2017 06:25 PM by Gerald H.)
Post: #4
RE: HP 50g: Mantissa of an Extended Real
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.
Find all posts by this user
Quote this message in a reply
10-07-2017, 06:33 PM
Post: #5
RE: HP 50g: Mantissa of an Extended Real
(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?
Find all posts by this user
Quote this message in a reply
10-07-2017, 07:38 PM (This post was last modified: 10-07-2017 07:39 PM by Gerald H.)
Post: #6
RE: HP 50g: Mantissa of an Extended Real
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.
Find all posts by this user
Quote this message in a reply
10-07-2017, 07:46 PM
Post: #7
RE: HP 50g: Mantissa of an Extended Real
Sorry, I must have erred in copying the instructions, on recompiling the negatives are dealt with correctly.
Find all posts by this user
Quote this message in a reply
10-07-2017, 07:55 PM
Post: #8
RE: HP 50g: Mantissa of an Extended Real
(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 )
   ;
;
Find all posts by this user
Quote this message in a reply
10-07-2017, 09:36 PM
Post: #9
RE: HP 50g: Mantissa of an Extended Real
Quite informative, thank you.
Arno
Find all posts by this user
Quote this message in a reply
10-08-2017, 06:42 AM
Post: #10
RE: HP 50g: Mantissa of an Extended Real
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.
Find all posts by this user
Quote this message in a reply
10-08-2017, 07:43 AM
Post: #11
RE: HP 50g: Mantissa of an Extended Real
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
Find all posts by this user
Quote this message in a reply
10-09-2017, 10:17 AM
Post: #12
RE: HP 50g: Mantissa of an Extended Real
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.
Find all posts by this user
Quote this message in a reply
10-09-2017, 02:45 PM
Post: #13
RE: HP 50g: Mantissa of an Extended Real
(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!
Find all posts by this user
Quote this message in a reply
10-10-2017, 06:32 PM
Post: #14
RE: HP 50g: Mantissa of an Extended Real
(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

Hardware: Hp48S - Hp50g (5x black + 1 blue) - HP39gII - Hp27s - Casio fx-CG50
Find all posts by this user
Quote this message in a reply
10-10-2017, 06:39 PM
Post: #15
RE: HP 50g: Mantissa of an Extended Real
Nowhere as yet, should however probably shortly appear at

http://www.hpcalc.org/
Find all posts by this user
Quote this message in a reply
10-13-2017, 05:41 AM
Post: #16
RE: HP 50g: Mantissa of an Extended Real
(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
Find all posts by this user
Quote this message in a reply
10-13-2017, 06:52 AM
Post: #17
RE: HP 50g: Mantissa of an Extended Real
(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!

Hardware: Hp48S - Hp50g (5x black + 1 blue) - HP39gII - Hp27s - Casio fx-CG50
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)