[uClibc]printf and floats

Manuel Novoa III mjn3 at uclibc.org
Thu Oct 4 17:35:28 UTC 2001


On Thu, Oct 04, 2001 at 11:33:20AM +0100, Ian Leonard wrote:
> 
> I tracked this problem to a lack of support for long doubles in the 
> compiler. Both printf.c and dtostr.c are effected.
> 
> My quick fix was to change all long doubles to doubles (in about five
> places).
> 
> 
> The configuration has an option to exclude the use of long doubles
> in libm but not libc. 

That should probably be changed.  Note that scanf.c will need changing
as well as printf.

> Also dtostr is complex in it's handling of exponents so I am not sure
> about the ramifications of this quick fix. 

There shouldn't be much difference in normal use.  You'll lose a few
significant digits when scaling values with very large or very small
exponents, but dtostr already loses some significance in those cases
anyway.  For everyday floating point values though, it does a reasonable
job.  It is larger than I'd like it to be (generated code size), and
I had planned to look at it again to try to come up with a better
implementation, but I haven't found the time.

Manuel





More information about the uClibc mailing list