avr-chat
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [avr-chat] Bug in atof shipped with avr-libc?


From: Weddington, Eric
Subject: RE: [avr-chat] Bug in atof shipped with avr-libc?
Date: Thu, 24 Feb 2011 05:46:11 -0700

Please fill out a bug report at the avr-libc project on the Savannah website.

https://savannah.nongnu.org/projects/avr-libc

Otherwise, your email will get lost quickly in our inboxes.

Eric

> -----Original Message-----
> From: address@hidden [mailto:avr-
> address@hidden On Behalf Of
> address@hidden
> Sent: Thursday, February 24, 2011 12:43 AM
> To: address@hidden
> Subject: [avr-chat] Bug in atof shipped with avr-libc?
> 
> Hi all:
> 
> I think I've found a bug in the version of atof that ships with the
> latest/last version of Winavr.
> 
> When I pass it a string with a floating point number, the number it
> returns is incorrect.
> 
> For example, I can pass it '-1033\0', and the result is something like -
> 15640. Similarly, I can pass it '0.33', and the result is 16000 and
> something. It seems that the only thing it gets right are the sign and
> when the input string is '0.00'.
> 
> I have reimplemented atof as my_atof, and it works perfectly.
> 
> Note that this incorrect behaviour is also apparent in avr-gcc shipped
> with ubuntu 10.04.2.
> 
> An example of code that demonstrates the behaviour is below:
> 
> float atof_test(void){
>       static char buf[10];
>       char* pbuf = buf;
> 
>       buf[0] = '-';
>       buf[1] = '0';
>       buf[2] = '.';
>       buf[3] = '3';
>       buf[4] = '3';
>       buf[5] = '\0';
> 
>       return atof(pbuf);
> }
> 
> Cheers,
> --
> Matt van de Werken
> Electronics Engineer
> Mining Geoscience, CSIRO Earth Science and Resource Engineering
> 1 Technology Ct   Pullenvale   QLD   4069
> P: 07 3327 4142  F: 07 3327 4455  M: 0400 538 608
> E: address@hidden
> "Those that do not understand UNIX are condemned to reinvent it, poorly"
>   - Henry Spencer
> _______________________________________________
> AVR-chat mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/avr-chat



reply via email to

[Prev in Thread] Current Thread [Next in Thread]