# Microsoft Windows Calculator Bug, Sqrt(4) – 2 != 0

Yesterday we posted about a bug found in **Windows 8**:

Windows 8 Taskbar Context Menu Bug

And now its turn of Windows **Calculator**. Almost all Windows users use the default Calculator application which comes preinstalled with Windows OS. But did you know it contains a bug which has not been fixed by Microsoft yet. This bug exists in almost all Windows versions including Windows XP, Vista, 7 and Windows 8.

The bug appears when you try to calculate following:

sqrt(4)-2

If you can't understand the above mentioned equation, lets describe it in details. The above command first calculates Square root of 4 and then subtracts 2 from the result.

**Square root of 4 is 2** and when we subtract 2 from it, the end result should be **2-2=0** but Calculator shows a long series of numbers in the result.

If you use the Standard mode of Calculator, the result would be displayed as **-1.068281969439142e-19** and if you use Scientific mode, you'll get the result as **-8.1648465955514287168521180122928e-39** as shown in following screenshot:

Its definitely a bug in Calculator. You might get different result in different Windows versions but the result will never be correct i.e. 0.

Following video shows the bug live in action:

The only reason behind this bug which I can figure out might be the way computer calculates square root. The square root of 4 is calculated as 1.9999..... up to infinite by computer and it shows the result as 2 using the round off mechanism. And when we subtract 2 from the result, it actually subtracts it from 1.9999..... up to infinite and shows the big series of numbers in minus.

Anyway after all the facts or assumptions, its definitely a bug similar to Notepad bug which also exists in all Windows versions:

**Notepad Statusbar Bug Found in All Windows Versions**

*Thanks to our reader "Anish Mehta" for sharing this bug...*

Share this article:Facebook | Twitter | Google+ | Reddit | Tell a friend

Posted in:Windows 7, Windows 8 / 8.1, Windows Vista, Windows XP

## Other similar articles that may interest you

- Microsoft Removes “Get Windows 10” (GWX) App from Windows 7 and 8.1 Computers
- How to Add “God Mode” Shortcut in Desktop Context Menu in Windows 7 and Later?
- Add “Windows Apps” Cascading Menu in My Computer Context Menu in Windows 7 and Later
- [Solution] “Play All” Option Opens “Copy Items” and “Move Items” Dialog Box in Windows XP
- nLite: Freeware to Integrate Service Packs, Drivers and Create Unattended Bootable ISO of Windows XP
- [FIX] Windows Vista or Server 2008 Computer Hangs and Stops Responding While Applying User Settings at Login Screen

TitoNot only this, (root of 16)-4 also not equal to 0 ;)

VG^^ Absolutely. It seems the bug only appears when the number to be subtracted is equal to the resulting number.

SCBrightIt's a round problem for sure, if you calculate int(sqrt(4))-2 the result will be zero.

macpro622776There's a typo in the article: "Its definitely a bug in Calculator. You might get different result in different Windows versions but the result will never we correct i.e. 0.", it should be "never be correct".

Other than that, interesting find.

cclloydEven with parntheses, it doesn't get it right.

Rtyh-12But 1.9999999... to infinity is equal to two. That should make no difference, so there must be another explanation.

Randy Collinssqrt(2)- sqrt(2) shows a perfect zero, hence there cannot be any bug

V!3My maths is weak.....lol

ticomfreakI get the same bug in the default Windows Phone calculator too. Haha.

UewdFaced exactly the same thing in Windows 8 CP 64-bit. Great find. :D

SMBRI know this bug is firstly seen in Youtube Video, User Name: wizaryan

NSDCars5Knew it long ago. Saw some "Windows XP Tricks" video, and XP showed like -2.042 etc. BTW, that was SP2. SP3 is same as Win7.

Fernozzle-8.1648465955514287168521180122928e-39 is another way to write -0.0000000000000000000000000000000000000081648465955514287168521180122928.

THIRTY-NINE zeros! I'd say that that's accurate enough for most cases.

JamesIt's not really a bug.

The calculator uses float data-type to manage the values. So, the numbers that "never ends" are never exact. The reason why it uses floats, is for efficiency. This "bug" exists in many advance calculators that you buy at the store, and under Windows, it existed possibly well before Windows 95.

IBM has a page on that:www-01.ibm.com/support/docview.wss?uid=swg21608991

Kent WillardThe "bug" also appears in the calculator of Windows XP, which is a pretty lousy trig calculator - it has *NO* square root, sin, cos, etc. buttons. To compute the square root of a value you have to raise to a decimal- fraction exponent:

Sqrt(4) has to be entered as 4 ^ 2 [1/x] = and displays "2"... then subtract 2 and you get

-8.1648465955514287168521180122928e-39

same result as shown in the published example.

Kitten S.That is so strange!!!! I did this using Windows XP Calc and it just showed up with that. Did it with a REAL calculator and it totalled zero and not -8.16484etc.

Theo HupkensThere is a serious bug in this calculator (at least in the Dutch version): the calculator, when used in 'standard mode' does not know about standard precedence rules.

For instance

Standard mode: 1 + 9/40 = 0,25;

Scientific mode: 1 + 9/40 = 1,225 (which is the correct answer).

Maybe this is not a bug after all, but a feature...

Genius SnobIf I may i'd like to explain why the scientific calculator has thes "problem". It is true that the normal calculator has a bug. But you have to know that at a scientific calculator the brackets count. That means that the actual calculation would be: sqrt(4)-2 equaling to 0. Sorry Guys

JayIt has basic error also.

For example,

5*5*5 + 3*3*3 should be 152 but windows 8.1 calculator's answer is 1152 with standard mode.

It's so stupid to use this calculator.

MarioIn Windows XP in standard mode its 8.1648465955514287168521180122928e-39 but in scientific mode I can't do that.

PaulThis is unnecessary ranting, which lacks of a decent amount of investigation. There is no closed form to calculate the square root (pls see en.wikipedia.org/wiki/Methods_of_computing_square_roots), thus every square root you will ever be calculating is an approximation. Of course you can define special cases, such as 4, 9, 16, 25, 36, 49, 64, 81, 100, ... but (a) this would mean, that you'd have to introduce some sort of semantics to a quite simple tool like the calculator, which would definitively be an overkill and (b) where do you stop? Anyone might complain, that 12398765-sqrt(153729373525225) is 5,3026330757729108494341053894116e-31 and not 0. [ironic]This definitively is a bug![/ironic]

You would not try to make any andvanced numeric calculation with the windows calculator. Would you? For literally every problem solved with the windows calculator -8e-39 will be sufficiently close to 0.

Matthew Doyle Jr.I just checked, and this same bug is in the windows 10 calculator! lol

LM HessThis bug only occurs if the answer is supposed to be zero.

sqrt(4) minus any number other than 1 gives the correct answer

sqrt(9) minus any number other than 3 gives the right answer.

sqrt(25) minus any number other than 5 gives the correct answer

. . . . . and so on.

Darth VaderI am getting result 14 for 5 + 2 * 2. It that ok?

Marcel@Randy That is incorrect. The bug is in the SQRT op. When performing the same calculation twice, the result is the same. It is perfectly consistent. The problem is the result is not perfectly accurate. It would be good if we could see the bitwise representation of the results of the sqrt op.

The algorithm used is incapable of finding the root of several perfect square numbers. That is what we know.

MohammedDate Calculation is also wrong in default micro soft calculator as it is showing 1 day less while calculating for a period of one month or more days..

FarnooshThe weird point is why the result of 4^0.5 - 2 is different from sqrt(4) - 2, shouldn't they have same algorithms of calculation?!