problem with atof / sscanf / strtof and float's range

Mathias.Krause at de.telex.com Mathias.Krause at de.telex.com
Mon Dec 4 08:36:47 UTC 2006


> > > [...]

> There is a limit on the number of _significant_ digits _considered_ in 
the
> conversion, since you can only represent so many in a float.  But all 
digits
> are read.

Yes. That's how it should be.

> You're test works find for me.  scanf, atof, and strtof all convert to
> inf for me on mipsel, since your value is larger than the max
> representable by a float. But while the standard guarantees that strtof
> will set errno to ERANGE in this case (which I see in my tests), it does
> not make such guarantees with either scanf or atof.

That's fine. It would be enough if the converted value is reproducable 
with 
being s.th. like INF, or if the function just returns with an error if my 
value is larger than the max representable.

> That leaves the question... why are you seeing -0.000000 from printf. 
What
> arch are you running on?

We're running uCLinux (dist 20060803) with kernel 2.4 and it's uClibc
on a Coldfire MCF5272 processor.

Mathias




More information about the uClibc mailing list