Post Reply 
(49G) Convert Integer from Integer Base A to Integer Base B
07-16-2022, 12:54 PM (This post was last modified: 08-20-2022 04:31 AM by Gerald H.)
Post: #5
RE: HP 49G: Convert Integer from Integer Base A to Integer Base B
Following John's suggestion in Post #2 the programme looks like this:

Code:
CKSUM # E678h

BYTES 103.5

« → A B
  « REVLIST OBJ→ 0. 1. ROT
    START A * +
    NEXT { } SWAP
    DO B DUP2 / IP UNROT MOD ROT + SWAP DUP NOT
    UNTIL
    END DROP
  »
»

This now permits the use of real numbers as a base, eg

For stack

{ 7. 8. 9. 7. 8. 9. }

10.

1.41421356237

the programme returns

{ 1. .58578643763 1.17157287526 1.34314575052 1.10050506341 .44365081393 .37258300208 .47308806549 .33095244179 .53196256861 .24769132121 .64971157485 .08116908005 .88520958733 .74812459773 .94199204992 .66782207072 .0555569751 .92143057907 .69690038783 .0144340334 .97958721329 .61465450443 1.13074730184 1.40088188412 .01885391657 .9733366435 .62349427077 1.11824616226 .4185614168 1.40806519978 1.00869570886 .57348971245 1.18896429298 .31855230016 .54950146122 .22289103795 }

On entering the two stack levels

1.41421356237

10.

the programme then returns

{ 7. 8. 9. 7. 8. 9. }
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HP 49G: Convert Integer from Integer Base A to Integer Base B - Gerald H - 07-16-2022 12:54 PM



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