X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f From: Hans-Bernhard Broeker Newsgroups: comp.os.msdos.djgpp,comp.lang.c++ Subject: Re: Weird double problem?! Date: 10 Apr 2002 09:20:59 GMT Organization: Aachen University of Technology (RWTH) Lines: 19 Message-ID: References: <142c67c0 DOT 0204092338 DOT 1ce7acb3 AT posting DOT google DOT com> NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de X-Trace: nets3.rz.RWTH-Aachen.DE 1018430459 1023 137.226.32.75 (10 Apr 2002 09:20:59 GMT) X-Complaints-To: abuse AT rwth-aachen DOT de NNTP-Posting-Date: 10 Apr 2002 09:20:59 GMT Originator: broeker@ To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com In comp.os.msdos.djgpp Taras wrote: > is assigned the value of 0.1, in the watch window it says the value is > 0.10000000000000001. Memorize this for the future: In computing 10.0 times 0.1 is hardly ever 1.0 The problem is that binary floating point can't exactly represent 1/10. It behaves like 1/7 does in decimal arithmetic: you get an infinite periodic fraction, which will be cut off somewhere, and thus lead to rounding error. As a rule of thumb: never believe the last digit of a floating point number. -- Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) Even if all the snow were burnt, ashes would remain.