From: Horst Kraemer Newsgroups: comp.os.msdos.djgpp Subject: Re: modf BROKEN ?? Date: Tue, 01 Aug 2000 19:37:54 +0200 Lines: 20 Message-ID: References: NNTP-Posting-Host: a11e2.pppool.de (213.6.17.226) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: fu-berlin.de 965151443 6010865 213.6.17.226 (16 [27606]) X-Newsreader: Forte Agent 1.8/32.548 trialware To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com On Mon, 31 Jul 2000 22:37:40 -0400, Radical NetSurfer wrote: > Why does the following program INCORRECTLY display > the fractional part? It does display CORRECTLY the fractional part. The problem is that you think that adding up 20 times the floating point value 0.1 will yield exactly 2.0. The number 0.1 isn't exactly representable as a binary floating point number. Adding up the "wrong" binary value associated to '0.1' will increase the representation error. Using FP numbers as contrl variable in a loop is almost always an error. Regards Horst