Post Reply 
HP 50g Base Conversion
02-06-2014, 08:17 PM
Post: #1
HP 50g Base Conversion
Hello friends,

I don't know wether the HP 50g has a build in function for base conversion of integer in exact mode. The program "T2BAS" convert every number in base ten to a choosen base. The program "BAS2T" do it the other way. My programs works with a special out- and input, you kann see it below.


Stack 5: 451
Stack 4: 7
Stack 3: 7:{"1" "2" "1" "3"}
Stack 2: 7:{"1" "2" "1" "3"}
Stack 1: 451

Stack 5 shows the number 451 stack 4 the number 7 this number is the new base
on stack 3 you see the output of "T2BAS": a tagged list with the digits new based.
the tag shows you the base.
stack 2 is the input for "BAS2T" and gives you the output on stack 1.

Remark: the base and the digits are always given in base 10, the programs functioned well for example base 234 (digit range from 0 to 233) or 17 and so on.

Here is the code:

"T2BAS"

Code:
%%HP: T(3)A(R)F(,);
\<< { } \-> N NB LRES
  \<<
    WHILE N NB \>=
    REPEAT N NB IDIV2 \->STR LRES + 'LRES' STO 'N' STO
    END N \->STR LRES + NB \->TAG
  \>>
\>>

"BAS2T"

Code:
%%HP: T(3)A(R)F(,);
\<< OBJ\-> OBJ\-> 0 \-> LIN OB N
  \<<
    WHILE LIN SIZE 1 >
    REPEAT LIN DUP HEAD OBJ\-> N + OB * 'N' STO TAIL 'LIN' STO
    END LIN HEAD OBJ\-> N +
  \>>
\>>

Greetings
peacecalc
Find all posts by this user
Quote this message in a reply
02-12-2014, 07:39 AM
Post: #2
RE: HP 50g Base Conversion
yes, the HP-50G has a base conversion functionality built in. You'll find it by pressing keys left-shift then 6 (Convert), then option 2 (Base). From there you can change the base to Hex, Dec, Oct and Bin and can access the conversion function R->B (decimal to whatever base you choosed) and B->R (the other way round). I've tried it out with exact mode activated and it works.

All that is described in chapter 19 of the user guide.

So your programs have the advantage to work with any base, not only 2,8,10 and 16. Thank you very much for your contribution.

Best regards

Karl
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: