The Museum of HP Calculators
This program is supplied without representation or warranty of any kind. Jamie Cox and The Museum of HP Calculators therefore assume no responsibility and shall have no liability, consequential or otherwise, of any kind arising from the use of this program material or any part thereof.
The HP-16C is HP's famous programmable programmer's calculator. It includes basic arithmetic functions in floating point as well as logical and math operations on integers in four bases. The biggest weakness of the calculator is that it isn't easy to convert between float and integer displays. This program overcomes this limitation by providing short subroutines for these functions.
These functions make the calculator much easier to use.
This program provides handy subroutines to convert between integer and floating point modes for the HP-16C. Although the calculator does most of the work, the result doesn't automatically appear in the display as you would expect. Use these subroutines to set the calculator to the desired mode while converting the display to the new mode. Any fractional part is truncated when changing to integer.
Conversion to integer uses 32-bits words in hex with leading zeros. This is a personal preference. You could just as well use, say, 16-bit words in octal without leading zeros.
After entering the program,
Press GSB A to convert a floating point number
to integer (hex).
Press GSB 9 to convert an integer (any base) to a floating point number.
Warning: If the number in the display is too big to fit in 32 bits, it will be silently truncated during either conversion.
# HP-16C Integer-to-Float/Float-to-Integer # -Jamie Cox # Usage: # Press GSB A to convert a float number to 32-bit HEX # Press GSB 9 to convert an integer to float # Mnemonic: A is a hex digit, 9 is a decimal digit. # A & 9 are at opposite ends of the keypad # # 001 43,22,A g LBL A # Convert Float to Integer 002 23 HEX # Leaves value in Y and shift count in X 003 42 F RRn # Apply shift 004 2 2 # 20 Hex gives 32-bit wordsize 005 0 0 006 42 44 f WSIZE 007 43,4,3 f SF 3 # display leading zeros 008 43 21 g RTN 009 43,22,9 g LBL 9 # Convert Integer to Float 010 0 0 011 42, 45,3 f FLOAT 3 # Set # digits after decimal 012 43 21 g RTN # That was easy
Written by Jamie Cox
Go back to the software library
Go back to the main exhibit hall