Crazy windows calculator!?


How many of you like maths ? Not many I guess. .😛 (i am not a big fan either)

but here is a simple calculation which I am sure you all can do easily:

what is the value of sqrt(4) – 2 ?

Is you answer 0 (zero) ? are you sure? check again..  try using the windows calculator..

when you do this.. sqrt(4) – 2 it will give some answer like this : -8.1648465955514287168521180122928e-39

similarly you will get unexpected result for sqrt(9) – 3 , sqrt(25)-5  etc…

now why is that? by simple logic we can see that sqrt(4) = 2 and 2 – 2 = 0 therefore, the answer should be zero. Check it using a normal calculator – it gives correct result. Check it using Ms excel it will also give the correct result (i.e. zero) So then whats with that strange looking value up there? has Windows calculator gone mad? Is that a Bug?

Explanation:

While some might call it a bug, it actually has some logical reason to it. The result is actually something times e -39 which come out to be  a very small decimal number now that happens because of the way computers handle floating point numbers.

The calculator actually stores some extra decimal points to account for the error,

for example 1/3 = 0.33333333333 can be stored up to only a limited number of 3’s where as in reality there are infinite number or 3’s after the decimal but its not possible to store it. so there would be some error. But while displaying the result the computer rounds it off and hides the result. i.e 2.0000000000000000000000000000001 would be displayed as 2 only similarly sqrt(4) also has some error which gets stored in the memory but isn’t displayed when the user does sqrt(4) = 2 (rounded off)

So the value which you are seeing is actually the round off error which gets stored by windows.

Posted on October 11, 2011, in Try this at home and tagged , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: