Message-ID: <32A02E68.5A61@pobox.oleane.com> Date: Sat, 30 Nov 1996 13:54:00 +0100 From: Francois Charton Organization: CCMSA MIME-Version: 1.0 To: afonso AT inesca DOT inesca DOT pt CC: djgpp AT delorie DOT com Subject: Re: Problems with DJGPP V2.01 - atof() function References: <329e68a5 DOT 10316617 AT news DOT ua DOT pt> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit afonso AT inesca DOT inesca DOT pt wrote: > > Problems with DJGPP V2.01 - atof() function > > Hi! > > Recently I've made an upgrade of my application from V1.xx > to V2.01 of DJGPP. In V1.xx my application is working properly. > After all the corrections I made in source files, due to > the changes in DJGPP Include files, I finally obtained an > executable file. But, when I tried to execute it, I got a crash > of my application! I made a debug and I found the cause of my > crash that is an incorrect return of atof() function. I'm using > it as in the example below: > > 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). > I think that problem is a bug of DJGPP Library V2.xx. Not in the library but in the compiler (I'd say) To work around, just do: char string[]="1.13"; float f; int result; ... f = (int)(atof(string)*100); result= (int) f; result should now be 113... Francois