From: terra AT diku DOT dk (Morten Welinder) Newsgroups: comp.os.msdos.djgpp Subject: Re: Problems with DJGPP V2.01 - atof() function Date: 29 Nov 1996 15:00:17 GMT Organization: Department of Computer Science, U of Copenhagen Lines: 19 Sender: terra AT tyr DOT diku DOT dk Message-ID: <57mtq1$4mo@vidar.diku.dk> References: <329e68a5 DOT 10316617 AT news DOT ua DOT pt> NNTP-Posting-Host: tyr.diku.dk To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp afonso AT inesca DOT inesca DOT pt writes: > char string[]="1.13"; > int result; > ... > result = (int)(atof(string)*100); > ... > I've got result = 112!!! not 113 as I wished, because >the function atof() return is 1.29999... not 1.13 (and I only have >an old i386). Getting 112 is well within the C standard. If your program does not work in this situation then you have a bug. Floating point numbers are not exactly represented; you will see rounding errors. Morten