[comp.sys.atari.st] LaserC ASCII to floating point conversion

jlf@cs.wvu.wvnet.edu (Jack L Forester) (09/26/90)

Has anyone out in the ST net.world had problems with Laser C's floating point
conversions to from ASCII to FP?  More specifically, with numbers in
scientific notation?  I've used atof and sscanf and both seem to ignore the
"e" part.  My code contains the following declarations:

char *buffer;
float float_num;

buffer is pointing to a string that contains "2.34e+02\0" and everything
I've tried returns the value 2.34 in float_num.  Here's what I've tried:

float_num = (float) atof(buffer);
sscanf(buffer, "%f", &float_num);
sscanf(buffer, "%e", &float_num);
sscanf(buffer, "%g", &float_num);

I'm using version 2.1 of LaserC.  I'd hate to have to write my own conversion
routines, but I need this to work by Friday and this is the last problem I'm
having.

If this is a bug in the library routines, does anybody have the sources for
a conversion routine that does work?  No need to waste bandwidth so please
reply by mail to the address below (that is if our news poster doesn't eat
my .signature).  Thanks to all in advance.


--
Jack Forester, Jr.          * Disclaimer:  My opinions are mine and mine     *
jlf@a.cs.wvu.wvnet.edu      *              alone!  I don't share my opinions * 
West Virginia University    *              with anyone!  :-)                 *
Dept. of Computer Science   *                                                *