On 26 Jul, 2006, at 16:52, abuzer.salik@xxxxxxx wrote:
Hi,
I have an application which uses double values a lot. If I try to
put say
401.74 in a double variable it is getting stored as 401.74000000000001
which creates problem in the calculations down the line. ( I am
checking
these values using gdb debugger).
So, I am wondering if there is a way by which I can store the correct
values (i.e. 401.74) in the double.
Use a library of rationals if you need exact values, I think GMP
provides one.
Do we need to look for another compiler/hardware or current setup can
handle this?
As long as you use doubles, which are tied to the hardware, you'll
have the same problem. The precision is more or less standard across
architectures. IOW it has little to do with the compiler.