Windows Calculator invalid input with 10^x function
tenforums.com
tenforums.com
powten(43429) -> Overflow
powten(43430) -> Invalid input
powten(4.3429) -> 22024.192788839535553954884105294
powten(4.3430) -> 22029.264630534561834283309977748
powten(4.3431) -> 22034.337640198758473587650545525
In Windows 10, 4.3431 results in "Invalid input" but 4.3429 does not. (Nor does 4.3430, but obviously so.)What's the significance of 43430?
What's the significance of 43430?
e^99999 = 1.0325137485899245994533393888277e+43429
e^100000 = 2.8066633604261231793183858185717e+43429
e^100001 = Invalid input for function.
(XP calc.exe)According to Mathematica,
e^100001 = 7.6293020112481304176946586569717e+43429
e^100002 = 2.0738593021001839250781552880629e+43430
and likewise, ln(1e+43429) = 99998.968003638410011217350885487
ln(1e+43430) = 100001.27058873140405690136887694
It's off by a tiny bit, but it's round enough to give some hints: 10^x is internally being computed using e^x.Edit: some more interesting, possibly relevant search results for the numbers 43429 and 43430:
https://stackoverflow.com/questions/33515746/why-is-this-c-p...
Holy crap. How on Earth did they manage to break Windows Calculator, of all things?
What's the sum of the numbers from 15 to 20 inclusive?
i.6 N.B. Returns an array 0 1 2 3 4 5
15 + i.6 N.B. Returns an array 15 16 17 18 19 20
+/ 15 + i.6 N.B. returns the number 105
edit: Or course, if we're talking about languages helpful for calculation, we simply must include a reference to https://frinklang.org/Personally I used to use Maple for this kind of thing circa 2002. It used to launch on Windows in a fraction of a second (faster than the built in calculator tool!), and was an amazing calculator for pretty much any purpose.
Unfortunately some version of Maple around that time switched to a Java-based front end, and thereafter took forever to load, and had a UI littered with glitches.
http://web.archive.org/web/20111213184700/http://download.mi...
(No, not the new abomination of the same name that comes up when you search for "Calculator Plus", but the original XP-era one that is now only available from archive.org. Irritatingly enough, MS removed the old --- and better --- one when they introduced the new one.)
The one from 7 up to 8.1 has its own problems:
Apparently a recent update also fixed a longstanding problem where the square root of a perfect square integer doesn't give you the exact right answer, so maybe there was a general change to the implementation of exponents and roots which may have introduced this bug too.
Googling around, I found another discussion on it:
https://www.eevblog.com/forum/chat/windows-10-calculator-bug...
My second guess is they are using some weird algorithm that hits an error case due to the limits of whatever number type they are using.
If n^(a/b) = (n^a)/(n^b) then 2^(1/2) = (2^1)/(2^2) = 2/4 = 0.5 but 2^(1/2) = sqrt(2) = 1.4...
It would be the 10000th root of 10^31415, and at this point what I'm saying is probably entirely unrelated to how it's really implemented.
It may have been the same update that made this change https://blogs.msdn.microsoft.com/oldnewthing/20180704-00/?p=...
In both instances, Apple didn't respond to the bug report until many years later, when they just closed it.
EDIT: and telemetry.
10^0,43407 - Invalid Input
10^0,00001 - OK
10^0,50001 - Invalid Input
10^0,40001 - Invalid Input
10^0,30001 - OK
10^0,35001 - OK
10^0,39999 - Invalid Input
10^0,37501 - OK
10^0,38751 - OK
10^0,39375 - OK
10^0,39794 - OK
10^0,39795 - Invalid Input
But when I tried better approximations things got weird 10^0,397941 - Invalid Input
10^0,397940000001 - Invalid Input
Seems six or more decimal places result in Invalid Input 10^0,39375 - OK
10^0,393751 - Invalid Input
10^0,39376 - OK
Even well outside the range 10^0,123456 - Invalid Input 5 digits - Valid: <=0.39794, Invalid: >=0.39795
10^0.39794 < 2.5
10^0.39795 > 2.5
6 digits - Valid: <=0.043429, Invalid: >=0.043431
7 digits - Valid: <=0.0043429, Invalid: >=0.0043431
8 digits - Valid: <=0.00043429, Invalid: >=0.00043431
The pattern seems to continue as the number of decimal places increases.10^0.0043429 ~= e^0.01
10^0.00043429 ~= e^0.001
So that gives some insight into the algorithm that is being used
base exponent (6 digits)
10 0.043429
11 0.041703
12 0.040243
2 0.144271
3 0.091024
4 0.072135
1000 0.014476
(the calculated exponent for two is actually 0.144270, but since it ends in zero the first failure occurs at 0.144271)Then again, the fact that they managed to break one of the most conceptually simple applications that comes with Windows --- for seemingly no good reason at all --- speaks volumes about the quality of MS products these days...
> Do you really think it is going to make much difference to the final answer?
Doesn't matter, it should work.
I see the same thing in travel forums frequently.
Great idea. Then there'll be absolutely no chance people will find a way to game the system.
I'm wondering if there are sites that have people on agreements to answer "200 posts/month" for a fixed pay or something, or get paid per answered question within 48h. In any case: it's not helping.
From both a technical and managerial standpoint, it can be insanely frustrating, with the only bright-side being that for very basic questions you at least get good coverage.
If you started out with a cleared calculator with default settings and computed 14479.14 - 152.36 you got 14326.78.
If you started out with a cleared calculator with default settings and computed 1143/78, and then computed 14479.14 - 152.36, you got something like 14326.779999999999.
The number of people on forums who completely missed the point and lectured me, often rather condescendingly, on how neither 14479.14 nor 152.36 are exactly representable in finite binary floating point and so that is why the subtraction was not exact was astonishing.
The bug is not that the subtraction is inexact. The bug is that the same subtraction result was displayed with different rounding depending on whether it was done immediately after a clear or done after computing 1143/78.
How 14479.14 - 152.36 displays should only depend on the calculator settings. That it changed depending on previous calculations suggest that there was probably a scratch variable used during calculations that was supposed to be reset before the next calculation but was not.
Speaking of the MacOS calculator, their RPN mode really annoys me (although not as much as Windows 10 calculator which doesn't even have an RPN mode!). Suppose you want to compute (2+3) x 4. The obvious key sequence works: 2 enter 3 + 4 x.
How about (2+3) x pi. The obvious key sequence is: 2 enter 3 + pi x. The result of that is an error beep with pi in the display, or, if you had anything on the stack before you started, that thing multiplied by pi.
That's because rather than pushing pi onto the stack, the pi key replaces whatever is on the bottom of the stack with pi. In other words, instead of acting as if you had hit the keys 3 . 1 4 1 5 9 ... 7 9 3, it acts as if it pops the stack, invokes the function
def pi(x):
return 3.141592653589793
on the value it popped, and pushes the result.What you have to do is: 2 enter 3 + enter pi x.
Suppose you decide you don't want to have to remember the distinction between the pi key and numerical entry, and decide to just always put in that enter.
So: 2 enter 3 + enter 4 x. That gives you 20 like you would expect...but also leaves a 5 on the stack above that.
For comparison, that does not happen on an HP-15, or on software calculators that follow HP RPN rules, such as pcalc on iOS. On those, when you press enter it duplicates the item currently on the top of the stack, just like Apple's calculator, but it sets a flag that says if you immediately enter a number, that overwrites the top of stack instead of pushing.
This flag was a key thing that made data entry on the HP calculators feel natural.
On the HP-48 they made a significant change to this. When you pressed enter it did not immediately dup the stack and set the flag saying numerical entry should overwrite. Instead, pressing enter did not immediately do anything to the stack. Instead, it set a flag saying that if your next action was to enter a number, first dup the top of stack.
The RPN mode on pcalc lets you select if you want HP-48 stack behavior or classic RPN behavior (it is in advanced settings when you are in RPN mode).
Here's an article on how RPN evolved at HP: http://h20331.www2.hp.com/hpsub/downloads/S07%20HP%20RPN%20E...
One day I will buy the DM42.
I don't really need it. But I _need_ it.
...and my guess is that "scratch variable" is actually a flag that switches calculations between fixed-point and floating-point mode; the first subtraction was done in fixed-point mode, but when it did the division it used floating-point, and then kept that mode for future calculations until explicitly cleared.
EDIT: Strangely, now all inputs seem to work, even 0.00001 and even when I restart the calculator. Not sure why ...
EDIT: Manually typing in 10, the x^y button, then 0.43407 also gives "Invalid input".
If that is true, then 0.00001 is being tread the same as 1, but 12345 and 0.12345 are both considered being "too large".
FWIW, I can't reproduce the bug with my current Windows build (1703 / 15063.296).
Edit: see comment below
This made me check and apparently IT here (large international networking hardware company) hasn't patched Windows since April. I always assumed everything auto updated, evidently our policy is the exact opposite.
[Version 10.0.17134.167]
1. Introduce a bug which only 1% would encounter. 2. Wait for it to get noticed. 3. Fix the bug, explain the causes in detail, thank everyone. 4. Profit ;)