From owner-freebsd-questions Thu Jan 16 15:28: 5 2003 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 11D5D37B401 for ; Thu, 16 Jan 2003 15:28:04 -0800 (PST) Received: from rutger.owt.com (rutger.owt.com [204.118.6.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id 70DF943F1E for ; Thu, 16 Jan 2003 15:28:03 -0800 (PST) (envelope-from kstewart@owt.com) Received: from owt-207-41-94-233.owt.com (owt-207-41-94-233.owt.com [207.41.94.233]) by rutger.owt.com (8.9.3/8.9.3) with ESMTP id PAA18602; Thu, 16 Jan 2003 15:28:00 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Kent Stewart To: Ugen , freebsd-questions@FreeBSD.ORG Subject: Re: printf prints WRONG double precision values Date: Thu, 16 Jan 2003 15:28:00 -0800 User-Agent: KMail/1.4.3 References: <3E272874.8060706@xonix.com> In-Reply-To: <3E272874.8060706@xonix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200301161528.00068.kstewart@owt.com> Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thursday 16 January 2003 01:47 pm, Ugen wrote: > Try this: > > #include > 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