Post Reply 
HP 49G: Challenge - Truncate a Long Real
07-07-2015, 04:48 PM (This post was last modified: 07-07-2015 05:54 PM by Gerald H.)
Post: #9
RE: HP 49G: Challenge - Truncate a Long Real
Bravo, Claudio!

Your programme works!

I include a code box for your programme to display it more clearly.

I haven't fully tested the programme yet, however for input

1.41421356237309E-12345

5.

it returns

0E-12345

Correct, but I prefer

0E0

Your programme is 435.5 Bytes while my latest version is 110 Bytes.

Code:

« SWAP ->H 0. -> N S TPOS

  «
    IF N 0 <
    THEN 15. N + 'TPOS' STO
    ELSE S 6. 10. SUB "339204000000000" SWAP + "0" + H-> DUP
      IF 50000. >
      THEN 100000. -
      END 14. SWAP - N - 'TPOS' STO
    END TPOS
    IF 15. >
    THEN 15. 'TPOS' STO
    END
    IF TPOS 0. >
    THEN S 1. 10. SUB "000000000000000" 1. TPOS SUB S 11. TPOS + 26. SUB + +
    ELSE S
    END H->
  »
»
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HP 49G: Challenge - Truncate a Long Real - Gerald H - 07-07-2015 04:48 PM



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