Why can't c# calculate exact values of mathematical functions

Posted by Timo Willemsen on Stack Overflow See other posts from Stack Overflow or by Timo Willemsen
Published on 2011-01-05T12:00:15Z Indexed on 2011/01/07 20:54 UTC
Read the original article Hit count: 169

Filed under:
|

Hey everyone,

Why can't c# do any exact operations.

Math.Pow(Math.Sqrt(2.0),2) == 2.0000000000000004

I know how doubles work, I know where the rounding error is from, I know that it's almost the correct value, and I know that you can't store infinite numbers in a finite double. But why isn't there a way that c# can calculate it exactly, while my calculator can do it.

Edit

It's not about my calculator, I was just giving an example:

http://www.wolframalpha.com/input/?i=Sqrt%282.000000000000000000000000000000000000000000000000000000000000000000000000000000001%29%5E2

Cheers

© Stack Overflow or respective owner

Related posts about c#

Related posts about rounding