Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Jan 2003 15:28:00 -0800
From:      Kent Stewart <kstewart@owt.com>
To:        Ugen <ugen@xonix.com>, freebsd-questions@FreeBSD.ORG
Subject:   Re: printf prints  WRONG double precision values
Message-ID:  <200301161528.00068.kstewart@owt.com>
In-Reply-To: <3E272874.8060706@xonix.com>
References:  <3E272874.8060706@xonix.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thursday 16 January 2003 01:47 pm, Ugen wrote:
> Try this:
>
> #include <stdio.h>
> int main()
> {
> double pi =3D 3.14159265358979323846 ;
>
>          printf("%20.19f\n", pi);
> }
>
> and here is what you get:
> host: [16:45] [127] /tmp>./test
> 3.1415926535897931160
>
>   The error in last 4 or digits is obvious. It seems
> that the culprit is __dtoa which incorrectly turns
> double precision numbers into strings.
> This is on FreeBSD 4.3 release..
>
> Ideas?

I thought that a 64-bit floating point was limited to around 16 digits.=20
That ends as ...793.

Kent
> --Ugen
>
>
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-questions" in the body of the message

--=20
Kent Stewart
Richland, WA

http://users.owt.com/kstewart/index.html


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200301161528.00068.kstewart>