07-18-2021, 05:00 AM
The following program splits a positive integer n into the sum:
n = a^2 + b
This technique is useful, especially with the HP 32S and HP 32SII. Normally, real numbers take up 9.5 bytes of memory on the HP 32S series. Integers 0 - 100 only consume 1.5 bytes of memory for the original HP 32S and the range is extended to 0 - 254 for the HP 32SII.
When the program terminates, b is on the X stack while a is on the Y stack.
Example: 684
Result:
Y: 26
X: 8
(26^2 + 8 = 684)
HP 41C/Swiss Micros DM41X Program: SQPLUS
HP 32S and HP 32SII Program: SQPLUS
n = a^2 + b
This technique is useful, especially with the HP 32S and HP 32SII. Normally, real numbers take up 9.5 bytes of memory on the HP 32S series. Integers 0 - 100 only consume 1.5 bytes of memory for the original HP 32S and the range is extended to 0 - 254 for the HP 32SII.
When the program terminates, b is on the X stack while a is on the Y stack.
Example: 684
Result:
Y: 26
X: 8
(26^2 + 8 = 684)
HP 41C/Swiss Micros DM41X Program: SQPLUS
Code:
01 LBL^T SQPLUS
02 FIX 0
03 ENTER
04 SQRT
05 RND
06 X^2
07 -
08 LASTX
09 SQRT
10 X<>Y
11 FIX 4
12 RTN
HP 32S and HP 32SII Program: SQPLUS
Code:
S01 LBL S
S02 FIX 0
S03 ENTER
S04 SQRT
S05 RND
S06 x^2
S07 -
S08 LASTx
S09 SQRT
S10 x<>y
S11 ALL
S12 RTN