I’ve been using PCs for the better part of two decades, and in all that time, I’ve used Windows’ calculator maybe four times. As such, that the following has never been noticed by me isn’t exactly surprising, and if the breadth of your experience with the program is anywhere as vast as mine, it’s not surprising that you haven’t noticed, either. But apparently, Windows’ calculator is lying to you.

According to Windows calculator, two minus two doesn’t equal zero.

That’s not exactly true, but kinda. Be a peach and open up Windows’ calc for a second, would you? Thanks, you’re the best. Alright, find the square root of four (using the square root button, not just hitting 2… even though it’s 2). Now subtract 2 from the resulting 2.

Should be zero, right? Isn’t that weird? Who knows how many long years this ghost has been in the machine. My guess: many.

**ADDENDUM**: A mathematically-inclined friend of mine has pointed out as I write this that the true square root of four is not, in fact, *exactly* two. So the ‘buggy’ answer we’re getting is apparently the true remainder of subtracting 2 from the square root of 4. For all intents and purposes, the number we’re getting is so close to zero it hurts, but it’s not entirely as erroneous as I’m making it out to be.

If you ask me, then, Windows calculator is just lying about that first 2 being 2.

Jerk.

https://www.youtube.com/watch?v=oBNyBhzu8zI

-8,1648465955514287168521180122928e-39 here running on Windows Seven.

I’m using the Windows Calculator since i’ve discovered it, but for some easy calcs only, never square roots or something like that (I got a calculator for that kind of calcs), and I’m surprised that i’ve never noticed something like that even not using them.

Ask for that friend of yours what he thinks about diferent results for the same “pointless” calc made in diferent versions of Windows Calculator.

My guess is that the algorithm the calculator uses to find square root is not perfect. Maybe they use a taylor approximation or something like that. Nice find though

How is the square root of 4 not precisely 2? That is complete nonsense. It’s actually +2 and -2 but it is an integer. Benjamin is probably actually correct. It’s an approximation algorithm that still exists from the early days of Windows.

Incidentally the same calculation on mac calculator is 0.

I think you either misunderstood your friend, or he was just telling you nonsense for kicks. The square root of 4 is 2. Period. Perhaps the entries for square root and multiplication in a dictionary could help clear this up for your friend if he seriously told you otherwise – I’d also say that in that case you’re the mathematically inclined of the two of you….clearly.

What you’re seeing is the cumulative effects of floating point precision errors…there’s no way around these in programs that use floating point numbers to perform calculations. The bottom line is that there’s just not very much detail in 32 bits, so not all numbers can be represented. 64 and 80 bit doubles are significantly better, but they are still not exact (and Microsoft’s compilers don’t even support 80 bit long doubles anyway, as far as I know, at least). The problem is most definitely not specific to Windows’ calculator. You’re closer than you realize about the lying comment, too. code like this: “if (abs(result)<epsilon) return 0;" is a common quick-fix when printing almost-zero results is distracting and/or misleading.

Google IEEE 754

I haven’t looked more into the actual problem with the calculator, but if type in 4 and get the square root of that it is 2. Now instead of trying 2, try subtracting 1….the answer is 1. The square of 64 is 8 and if you subtract 8 from that on the calculator it will be 1.10707409665568e-19. However, if you subtract 7 from that it will be 1. My guess is when you type that number Windows doesn’t see it, if it is the same number then you get the miscalculation. It could probably be fixed but until then just remember that 2-2=0 and so on…..thanks

I am on a Mac OS X Snow Leopard I just tried the calculator and the formula square for 4 minus 2 does equal 0. It seem that Apple know how to count better than Microsoft.

not so sure about OS X… try e.g. 1 minus 1.1 and you get 0.1 instead of -0.1. or 95 minus 95.6 and you get 0.6 instead of -0.6 etc. however the paper tape shows the correct results.