HP Forums

Full Version: HP 50g Base Conversion
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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:


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


%%HP: T(3)A(R)F(,);
\<< OBJ\-> OBJ\-> 0 \-> LIN OB N

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

Reference URL's