Saturday, August 16, 2025

RPN: HP 32S & DM42: Converting Real Numbers to Hexadecimal Approximations

RPN: HP 32S & DM42: Converting Real Numbers to Hexadecimal Approximations



Introduction


We know calculators that have base conversions easily convert integers to different bases. But what about all real numbers? Not so much. Today’s blog will tackle it.


The procedure given today should work for converting from decimal to octal, binary, and hexadecimal. I chose hexadecimal:


0.A B C D… _16

The digit A is in units of 1/16.

The digit B is in units of 1/16^2 or 1/256.

The digit C is in units of 1/16^3 or 1/4096.

The digit D is in units of 1/16^2 or 1/65536.

and so on.


Note: The procedure considers positive real numbers only.


Example: Convert 7.86 to hexadecimal using 4 places


In hexadecimal, 4 places translates to terms of 1/65536.


Separate 7.86 into its integer and fractional parts.

Integer Part: 7

Fractional Part: 0.86

Convert the fractional part to n parts of 65536. (16^4)*

0.86 * 65536 = 56360.96

Round n to the nearest integer. Use the formula: int(n + 0.5) = int(n + 1/2)

Int(56360.96 + 0.5) = 53361

(round(56360.96, 0) = 53361)

Convert both original integer part and the last result to hexadecimal.

Integer Part: 7_10 → 7_16

Frac in terms of 65536: 53361_10 → DC29_16

**If the fractional part has less than four* digits showing in the calculator, pad the converted part with zeros on the left.


The approximate answer reads as:

7.86_10 → 7.DC29_16

Recall in Hexadecimal:

A=10, B=11, C=12, D=13, E=14, F=15.


* precision: number of places.


HP 32S/HP 32SII/DM32 Code


H01 LBL H

H02 ENTER

H03 IP

H04 x<>y

H05 FP

H06 16

H07 4 (** - accuracy level, number of places)

H08 y^x

H09 ×

H10 2

H11 1/x

H12 +

H13 IP

H14 HEX

H15 STOP

H16 DEC

H17 RTN



HP 42S/DM42 Code


01 LBL “→HEX”

02 ENTER

03 IP

04 x<>y

05 FP

06 16

07 4 (** - accuracy level, number of places)

08 Y↑X

09 ×

10 0.5

11 +

12 IP

13 HEXM

14 STOP

15 EXITALL

16 RTN



When the program stops initially, the results are shown as follows:

Y: integer part

X: fractional part – right justified


Remember the number of places (precision) because if the fractional part has less digits, pad zeroes to the left.


Examples


n = precision = 4

Decimal

Y: Hex Integer

X: Hex Fractional (displayed)

Result (base 16)

3.5

3

8000

3.8000

π

3

243F

3.243F

√2

1

6A0A

1.6A0A

0.6732

0

AC57

0.AC57

0.0002

0

D

0.000D

e^4.1

3C

571D

3C.571D

8.2^1.7

23

C460

23.C460



Eddie


All original content copyright, © 2011-2025. Edward Shore. Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited. This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.


All posts are 100% generated by human effort.  The author does not use AI engines and never will.


Sunday, August 10, 2025

The Product Formula Chart Aid: P = A × B

The Product Formula Chart Aid: P = A × B


A Learning and Memorization Aid


A lot of mathematical formulas, basic relationships in physics and other applications are often in the form of:


P = A × B


where P is the product of two factors, A and B.


Examples include:


Distance: distance = velocity × time

Ohm’s Law: power = current × voltage

Newton’s Second Law: force = mass × acceleration


A chart in a shape of a circle (some people use a triangle) can be used to illustrate the relationship between the three variables.  I see charts of this time in various math books and videos applied to many applications.  An example is Ohm's Law as illustrated by Electrician U (skip to https://youtu.be/-oHzc_DbaGw?t=17).


P = A × B,  A = P ÷ B,  B = P ÷ A



Going across means multiply, while vertically means divide.


P = A × B

A = P ÷ B

B = P ÷ A





Hope you find this helpful,


Eddie


Source:  

Electrician U.  "5 Formulas Electricians Should Have Memorized!"  March 15, 2023.   https://www.youtube.com/watch?v=-oHzc_DbaGw.  Accessed May 27, 2025


All original content copyright, © 2011-2025. Edward Shore. Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited. This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.


All posts are 100% generated by human effort.  The author does not use AI engines and never will.


Saturday, August 9, 2025

RPN: HP 15C and DM32: Integer Length and Digit Extraction

RPN: HP 15C and DM32: Integer Length and Digit Extraction (up to 99,999,999)



The following programs are utilities for positive integers:


(1) Integer Length: how many digits in a positive integer

(2) Digit Extraction: Get the nth digit of a positive integer


Note:  Do not use more than 8 digits (integers up to 99,999,999).   Beyond this, the program may return inaccurate answers.  

Thanks to J-F Garnier for pointing out the limitation of the programs.  


Integer Length


Find the number of digits of a positive integer. The integer is decimal base (base 10).


For a positive integer n, the number of the digits can be easily found by the formula:


L = int(log(x)) + 1



DM32, HP 32S, HP 32SII Code


L01 LBL L

L02 LOG

L03 IP

L04 1

L05 +

L06 RTN


HP 15C, DM15 Code


001

42, 21, 11

LBL A

002

43, 13

LOG

003

43, 44

INT

004

1

1

005

40

+

006

43, 32

RTN


The program finds the number of digits in the positive integer in the X stack.


Examples:


X = 436782; Length: 6

X = 5195008; Length: 7

X = 23156956; Length: 8


Digit Extraction


Extract the nth digit of a positive integer. Digit positions go from left to right. For example: for the integer 4582, the 1st digit is 4, the 2nd digit is 5, 3rd digit is 8, and 4th digit is 2.


Steps that this program follows:

Step 1: Find the length of the positive integer. L = int(log(x)) + 1.

Step 2: Divide X by 10^(L – n + 1). D = X / (10^(L – n + 1))

Step 3: Extract the fractional part. D = frac(D)

Step 4: Multiple the result by 10 and extract the integer part. D = int(10 * D)


Setting up the stack:

Y: integer

X: nth digit to extract


Variables Used:

DM32, HP 32S, HP 32S II

HP 15C, DM15

X

R1

N

R2

L

R3



DM32, HP 32S, HP 32SII Code


E01 LBL E

E02 STO N

E03 R↓

E04 STO X

E05 LOG

E06 IP

E07 1

E08 +

E09 STO L

E10 RCL X

E11 RCL L

E12 RCL- N

E13 1

E14 +

E15 10^x

E16 ÷

E17 FP

E18 10

E19 ×

E20 IP

E21 RTN


HP 15C, DM15 Code


001

42, 21, 12

LBL B

002

44, 2

STO 2

003

33

R↓

004

44, 1

STO 1

005

43, 13

LOG

006

43, 44

INT

007

1

1

008

40

+

009

44, 3

STO 3

010

45, 1

RCL 1

011

45, 3

RCL 3

012

45, 30, 2

RCL- 2

013

1

1

014

40

+

015

13

10^x

016

10

÷

017

42, 44

FRAC

018

1

1

019

0

0

020

20

×

021

43, 44

INT

022

43, 32

RTN


Examples


Integers

Length

2nd Digit

4th Digit

5th Digit

436782

6

3

7

8

5195008

7

1

5

0

23156956

8

3

5

6



Eddie


All original content copyright, © 2011-2025. Edward Shore. Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited. This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.


All posts are 100% generated by human effort.  The author does not use AI engines and never will.


Saturday, August 2, 2025

AOS Calculators: Duplicating a Value Without Retyping It

AOS Calculators: Duplicating a Value Without Retyping It



Note: The following applies to scientific classic calculators who operate under the algebraic operating system (AOS) (that is what Texas Instrument’s calls it). I tested this procedure with the following calculators: TI-30X ECO, HP 10bII+ (Algebraic mode), and Casio fx-260 Solar.



Introduction: Going Back to 1976


Imagine it is 1976 and you have have an SR-56 from Texas Instruments. Here is what an SR-56 looks like: http://www.datamath.org/Sci/WEDGE/ZOOM_SR-56.htm


You are tasked to calculate 1.401103287^1.401103287 and do not want to write the number twice. According to page 53 of the SR-56 manual, one approach is to key in:


1.401103287 [ y^x ] [ CE ] [ = ]

Result: 1.604057054


For that particular calculator, SR-56, pressing [ CE ] once stores the number in the display as the second operand allowing the value to duplicated without having to retype the number.


If we tried that on a modern TI-30Xa/TI-30 ECO RS, the display would clear to zero instead of showed the previous number.


However, there are a few tricks we can employ to achieve the similar result.



Trick 1: Pressing the Reciprocal Key Twice


As long as the number in the display is nonzero, pressing [ 1/x ] [ 1/x ] registers the number in the display for as a second operand. In calculators operating in AOS, executing one-argument functions only operate and effect the number in the display only.


Pressing [ 1/x ] takes the reciprocal of the number and registers the number in the display. Pressing [ 1/x ] again returns the number.


**The keystrokes omits any [ 2nd ] or [ SHIFT ] keys.


Example 1:

Expression: x * log x

Keystrokes: x [ × ] [ 1/x ] [ 1/x ] [ LOG ] [ = ]


5.8 * log 5.8

Keystrokes: 5.8 [ × ] [ 1/x ] [ 1/x ] [ LOG ] [ = ]

Result: 4.427882363


Example 2:

Expression: x^x

Keystrokes: x [ y^x ] [ 1/x ] [ 1/x ] [ = ]


3.088 ^ 3.088

Keystrokes: 3.088 [ y^x ] [ 1/x ] [ 1/x ] [ = ]

Result: 32.51797379


Example 3:

Expression: x * sin x

Keystrokes: x [ × ] [ 1/x ] [ 1/x ] [ SIN ] [ = ]


50° * sin 50°

Keystrokes: ([DRG] to DEG/[ MODE ] (DEG))

50 [ × ] [ 1/x ] [ 1/x ] [ SIN ] [ = ]

Result: 38.30222216


4^4 + 1 / (3^3)

Keystrokes:

4 [ y^x ] [ 1/x ] [ 1/x ] [ + ]

[ ( ] 3 [ y^x ] [ 1/x ] [ 1/x ] [ ) ] [ 1/x ] [ = ]

Result: 256.037037


If the calculator has a cube function (x^3), we can execute this keystroke:

4 [ y^x ] [ 1/x ] [ 1/x ] [ + ]

[ ( ] 3 [ x^3 ] [ ) ] [ 1/x ] [ = ]



Trick 2: Inverse Function Trick


This trick extends the reciprocal trick to include a function that acts on two (and theoretically more) “reversible” functions. This trick applies to the expressions with the following format:


f(x) OP g(x)


f(x)

f^-1(x)

f(x)

f^-1(x)

f(x)

f^-1(x)

SIN

SIN^-1

e^x

LN

X^3

COS

COS^-1

LN

e^x

X^3

TAN

TAN^-1

10^x

LOG

Hyperbolic

Inverse Hyperbolic

SIN^-1

SIN

LOG

10^x

Inverse Hyperbolic

Hyperbolic

COS^-1

COS

X^2



TAN^-1

TAN

X^2




OP covers the arithmetic operations: [ + ], [ - ], [ × ], [ ÷ ], [ y^x ], and [ y^(1/x) ]


The general keystroke sequence is: x [ f(x) ] [ OP ] [ f^-1(x) ] [ g(x) ] [ = ]


Let’s illustrate this with a few examples. Assume the calculator is in degrees mode.


Example 1:

sin 40° * cos 40°

f(x) = sin x, f^-1(x) = sin^-1 x, g(x) = cos x

Keystrokes: 40 [ SIN ] [ × ] [ SIN^-1 ] [ COS ] [ = ]

Result: 0.492403877


Example 2:

tan 32° * sin 32°

f(x) = tan x, f^-1(x) = tan^-1 x, g(x) = sin x

Keystrokes: 32 [ TAN ] [ × ] [ TAN^-1 ] [ SIN ] [ = ]

Result: 0.331130307


Example 3:

log 881 * ln 881

f(x) = log x, f^-1(x) = 10^x, g(x) = ln x

Keystrokes: 881 [ LOG ] [ × ] [ 10^x ] [ LN ] [ = ]

Result: 19.97005314


Example 4:

e^3.5 / √3.5

f(x) = e^x, f^-1(x) = ln x, g(x) = √x

Keystrokes: 3.5 [ e^x ] [ ÷ ] [ LN ] [ √ ] [ = ]

Result: 17.70095363


Example 5:

4.555 + e^4.555

f(x) = √x, f^-1(x) = x^2, g(x) = e^x

Keystrokes: 4.555 [ √ ] [ + ] [ x^2 ] [ e^x ] [ = ]

Result: 97.24099983


The inverse function “recovers and registers” the original x. It’s kind of simulating the LAST x feature on RPN calculators.


Sources


Datamath. “Texas Instruments SR-56“ December 5, 2001. http://www.datamath.org/Sci/WEDGE/SR-56.htm


Texas Instruments. Programmable Slid-Rule Calculator SR-56: Owner’s Manual. Dallas, TX. 1976


Eddie


All original content copyright, © 2011-2025. Edward Shore. Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited. This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.


All posts are 100% generated by human effort.  The author does not use AI engines and never will.


RPN: HP 32S & DM42: Converting Real Numbers to Hexadecimal Approximations

RPN: HP 32S & DM42: Converting Real Numbers to Hexadecimal Approximations Introduction We know calculators that have base c...