Date: Thu, 6 Jan 2000 13:04:22 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: Niklas Pettersson cc: djgpp AT delorie DOT com Subject: Re: DJGPP BUG!!!!!!! ??? In-Reply-To: <851o9m$h4t$1@news.lth.se> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com Errors-To: dj-admin AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Thu, 6 Jan 2000, Niklas Pettersson wrote: > I think I have found an error in DJGPP... No, it's not a bug in DJGPP. > 0.1 0 > .. > .. > 0.9 0 > 1.0 1 > ... > > but 1.0 gets converted to 0!!!! The problem is that 0.1 doesn't have an exact binary representation, so it is converted to a number that is slightly less than 0.1. Therefore, 10 times that number is slightly less than 1.0. Printing that number with %f rounds the value to 1.0, but assigning it to an int *truncates* rather than rounds, and you get 0. I suggest to read some introductory book about numerical computations, it should explain this somewhere on page 3 or thereabouts...