From: mdruiter AT cs DOT vu DOT nl (Ruiter de M) Newsgroups: comp.os.msdos.djgpp Subject: Re: A question about atof() and the double 0.1 Date: 17 Jun 1998 13:59:39 GMT Organization: Fac. Wiskunde & Informatica, VU, Amsterdam Lines: 22 Message-ID: <6m8i4b$ijr$1@star.cs.vu.nl> References: <3587a411 DOT 12016463 AT news DOT polimi DOT it> NNTP-Posting-Host: sloep111.cs.vu.nl To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Roberto Sassi (sassi AT biomed DOT polimi DOT it) wrote: > OKAY > 0.10000000000000000555111512312578270212 > ERROR > OKAY > 0.25000000000000000000000000000000000000 > > As you can see, with the number 0.25, there is no problem. > Can You help me in understandig such a behaviour? Floating point numbers (float/double) have (of course) limited precision. Some numbers (e.g. 0.25) can be represented exactly in the used format, some (e.g. 0.1) cannot and must be approximated. Of course doubles have more precision than floats, but not ad infinitum. -- Groeten, Michel. http://www.cs.vu.nl/~mdruiter ____________ \ /====\ / "You know, Beavis, you need things that suck, \/ \/ to have things that are cool", Butt-Head.