Post Reply 
RPN-PRGM: New Windows console application emulating HP calculators
02-01-2021, 05:07 PM
Post: #14
RE: RPN-PRGM: New Windows console application emulating HP calculators
(02-01-2021 03:33 AM)Aacini Wrote:  I am open to any suggestion of a more precise method to perform this conversion.

1. since Exp is integer, scaling factor can be improved to give more precisions

S = 10^Exp = 2^(Log2(10)*Exp) = 2^(Log2(1.25)*Exp) * 2^(3*Exp)

First term is more accurate, because of more precise constant, and smaller exponent.
Second term is just a shift of binary exponents, thus exact.

lua> log2 = require'mathx'.log2
lua> Exp = 99
lua> 2^(log2(10)*Exp)
9.999999999999729e+098
lua> 2^(log2(1.25)*Exp) * 2^(3*Exp)
1e+099

2. ASM code hard-coded rounding mantissa to 19 digits, but ENG:P should round to P digits.

RPN: 92 eng:2
91.E+0000

RPN: 92 eng:6
91.9999E+0000

X = 92
P = 6
S = 10^(P-1 - floor(log10(X)) = 10^(5-1) = 1E4
round(X*S)/S = 920000E-0004 = 92.0000E+0000

3. this is a BUG.

RPN: 93 eng:6
92.2337E+0000
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: RPN-PRGM: New Windows console application emulating HP calculators - Albert Chan - 02-01-2021 05:07 PM



User(s) browsing this thread: 1 Guest(s)