Skip to content
brickpool edited this page Jul 22, 2020 · 1 revision

Number Theory and Algebra

Source: HP-45 Applications Book (HP 00045-90320 Rev. B Reorder 00045-66001, Dec 1974)


Base Conversions

Note:
Base conversation algorithms are given for positive values only. To convert a negative number, change sign, convert, and change sign result.

Decimal integer to integer in any base

I10 → Jb

In the following key sequence, f+1 is the number of digits in Jb.
di (i=1, …, f+1) represents the ith digit in Jb, counting from left to right, i.e.

Jb = (d1d2 --- df+1)b

For large numbers, Jb = (d1·d2 --- df+1)b * bf, see example 3.

LINE DATA OPERATIONS DISPLAY REMARKS
1 b ENTER ENTER
2 I +> STO A +> LN
3 x<>y LN ÷ D
4 <+ INTG 6'IP f Let f be the largest
  integer ⩽ D
5 x<>y ENTER ENTER RCL A
6 R↓ R↓ x<>y ÷ E1 di = integer part of Ei
  (i=1, …, f)
7 d1 - × E2
8 di - × Ei+1 Perform 8 for i=2, …, f
9 <+ DISPLAY 4'ALL Ef+1

Example 1: Convert 1206 to hexadecimal (base 16).
(The hexadecimal digits are 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F)

Answer: 120610 = 4B616 (f = 2)

LINE DATA OPERATIONS DISPLAY REMARKS
1 +> BASE 2'HEX hexadecimal mode
2 1206 1 2 0 6 ENTER 4B6h

Example 2: Convert 513 to octal (base 8).

Answer: 51310 = 10018

LINE DATA OPERATIONS DISPLAY REMARKS
1 +> BASE 3'OCT octal mode
2 513 1 2 0 6 ENTER 1001o

Example 3: Convert 6.023 × 1023 to octal.

Answer: 6.023 × 1023 = 1.77438 × 826

Note: If we consider 6.023 × 1023 to be a scientific mesurement good only to 4 significant digits, it is meaningless for the octal representation to contain more than 5 significant digits. Therefore, we stop before the loop is completed.

LINE DATA OPERATIONS DISPLAY REMARKS
1 8 ENTER ENTER 6 . 0
2 2 3 E 2 3
3 +> STO A +> LN
4 x<>y +> LN ÷ 26.33
5 <+ INTG 6'IP 26 f=26 (Note: this gives
  the exponent in base 8)
6 x<>y ENTER ENTER RCL A
7 R↓ R↓ x<>y ÷ 1.99 d1=1
8 1 - × 7.94 d2=7
9 7 - × 7.54 d3=7
10 7 - × 4.34 d4=4
11 4 - × 2.69 d5=5 (rounded), stop

Integer without exponent in base b to decimal

(d1d2 --- dn-1dn)b → I10
LINE DATA OPERATIONS DISPLAY REMARKS
1 b ENTER ENTER ENTER
2 d1 ×
3 di + × Perform 3 for i=2, …, n-1
4 dn ×

Examples:

  1. 7300204618 = 12374046510
  2. 7D0F16 = 3201510 (A = SIN, B = COS, C = TAN, D = √x, E = , F = 1/x input in hexadecimal mode)
LINE DATA OPERATIONS DISPLAY REMARKS
1 +> BASE 3'OCT octal input
2 730020461o 7 3 0 0 2
  0 4 6 1 +>
  BASE 7'o 730020461o
3 +> BASE 1'DEC decimal mode
LINE DATA OPERATIONS DISPLAY REMARKS
1 +> BASE 2'HEX hexadecimal input
2 7D0Fh 7 SIN 0 1/x +>
  BASE 6'h 7D0Fh
3 +> BASE 1'DEC 32015 decimal mode

Clone this wiki locally