This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: [Ask for help]: Met a problem with printf and gcvt
- From: Siddhesh Poyarekar <siddhesh dot poyarekar at gmail dot com>
- To: Wang Weidong <wangweidong1 at huawei dot com>
- Cc: "Joseph S. Myers" <joseph at codesourcery dot com>, Ryan Arnold <ryan dot arnold at linaro dot org>, Mark Brown <ms_brown at sbcglobal dot net>, "libc-help at sourceware dot org" <libc-help at sourceware dot org>
- Date: Tue, 9 Dec 2014 12:41:36 +0530
- Subject: Re: [Ask for help]: Met a problem with printf and gcvt
- Authentication-results: sourceware.org; auth=none
- References: <53566C6A dot 4050804 at huawei dot com> <5358058F dot 9010806 at sbcglobal dot net> <5358691A dot 1090104 at huawei dot com> <53598073 dot 9010809 at sbcglobal dot net> <535A100A dot 409 at huawei dot com> <535A6EC9 dot 30608 at sbcglobal dot net> <CAJE4xBPRDjSVe+EbKGimD9m4Dbcdt+iACVN9VYciuY35rAd5ng at mail dot gmail dot com> <535B8B25 dot 4090002 at huawei dot com> <Pine dot LNX dot 4 dot 64 dot 1404281354040 dot 16435 at digraph dot polyomino dot org dot uk> <54869FD2 dot 5050205 at huawei dot com>
On 9 December 2014 at 12:38, Wang Weidong <wangweidong1@huawei.com> wrote:
> When I was using the printf() and gcvt(), I got a difference below:
>
> ------------------------------------------------------------
>
> On Uclibc(0.9.31):
>
> printf("%.1f\n",3.25); ------>3.3
>
> gcvt(1e-100, 20, buf);
> printf("%s\n", buf); ------>1.0000000000000001e-100
>
> -----------------------------
>
> On Glibc(2.18/2.19/2.11):
>
> printf("%.1f\n",3.25); ------>3.2
>
> gcvt(1e-100, 20, buf);
> printf("%s\n", buf); ------>1e-100
>
> ------------------------------------------------------------
>
> Is it a problem on the uclibc or on glibc?
Obviously a problem with uclibc since it is losing precision.
Siddhesh
--
http://siddhesh.in