Post Reply 
RPN-PRGM: New Windows console application emulating HP calculators
02-02-2021, 03:19 AM
Post: #15
RE: RPN-PRGM: New Windows console application emulating HP calculators
We can produce more accurate 10^Exp with more bits for log2(10):

log2(10) = 0x3.5269e12f346e2bf924afdbfd36bf6d ...

Code:
-- k1 + k2 = rounded 95-bits of log2(10)
k1 = 0x3.5269e12f34
k2 = 0x0.00000000006e2bf924afdc

function pow10(n)   -- assume integer n
    local m = k1*n
    local e = floor(m + 0.5)
    return 2^(m-e+k2*n) * 2^e
end

lua> for i=-300,300,100 do print(i, pow10(i)) end
-300     1e-300
-200     1e-200
-100     1e-100
0          1
100      1e+100
200      1e+200
300      1e+300
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-02-2021 03:19 AM



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