[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: printf builtin bug?
From: |
Chet Ramey |
Subject: |
Re: printf builtin bug? |
Date: |
Mon, 27 Dec 2004 16:01:49 -0500 |
> Machine Type: i586-mandrake-linux-gnu
>
>
> Bash Version: 2.05b
> Patch Level: 0
> Release Status: release
>
>
> Description:
> printf builtin rounds some decimals incorrectly.
>
>
> Repeat-By:
> $ printf %.f 1.000000000000000000001; echo
> 0
> $ printf %.f 1.00000000000000000001; echo
> 0
> $ printf %.f 1.0000000000000000001; echo
> 1
> $ printf %.f 1.00000000000000000000; echo
> 1
The printf builtin doesn't really do any rounding itself. It calls strtold
to convert the argument and printf to print it. I'd say the problem lies in
the C library, especially since I can reproduce the above error only on
Red Hat Linux 8.0.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet )
Live...Laugh...Love
Chet Ramey, ITS, CWRU chet@po.cwru.edu http://tiswww.tis.cwru.edu/~chet/