delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/04/10/05:31:36

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
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: <a9105r$vv$1@nets3.rz.RWTH-Aachen.DE>
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 <tagas96 AT hotmail DOT com> 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.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019