[Icc-avr] atof-Difference string <> float

Bruce Parham obparham at jpl.nasa.gov
Thu Aug 7 16:47:26 PDT 2008


Rainer Dehnert wrote:

> Hi,
> 
> I've differences converting string to float(double).
> I'm using ICCAVR V7.18 Pro with Win XP.
> 
> The source:
> void main(void) {
> double lat;
> unsigned char string[] = "1234.123456";
> 
> //init_devices();
> 
> lat = atof(string);
> printf("string: %s\n\r", string);
> printf("float : %f\n\r", lat);
> }
> 
> The displayed results are:
> string: 1234.123456
> float : 1234.123168
> 
> Converting with Borland-Compiler the results are correct.
> 
> Where's my mistake?!
> 
> Many thanks.
> Rainer

To print a double don't you need to use %lf in the format?

Bruce



More information about the Icc-avr mailing list