help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: g++ 3.4.2 strange behavior


From: Ulrich Eckhardt
Subject: Re: g++ 3.4.2 strange behavior
Date: Mon, 01 Nov 2004 19:39:50 +0100
User-agent: KNode/0.7.7

Paul Schneider wrote:
[ (1000.0-0.0)/0.001 yields 99999 ]
> where it should be 100000 straight in my opinion. What am I doing wrong.

Try representing 0.001 in binary, it can't be done accurately, just as 1/3
can't in decimal. IOW, the computer has to use a value slightly lower or
higher, which is why your result differs from what you expect. 
The reason it didn't do so with the other number might be that they were
already computed at compile-time or with higher precision or with a
different algorithm. 

Uli

-- 
http://gcc.gnu.org/faq.html
http://parashift.com/c++-faq-lite/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]