delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/10/30/16:08:46

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
Date: Thu, 30 Oct 2003 23:00:54 +0200
From: "Eli Zaretskii" <eliz AT elta DOT co DOT il>
Sender: halo1 AT zahav DOT net DOT il
To: djgpp AT delorie DOT com
Message-Id: <6654-Thu30Oct2003230053+0200-eliz@elta.co.il>
X-Mailer: emacs 21.3.50 (via feedmail 8 I) and Blat ver 1.8.9
In-reply-to: <oprxuxfe0j0bb83x@news.mad.ttd.net> (message from
=?iso-8859-15?Q?Rafael_Garc=EDa?= on Thu, 30 Oct 2003 14:07:52 +0100)
Subject: Re: double with only 13 digit precision?
References: <oprxuxfe0j0bb83x AT news DOT mad DOT ttd DOT net>
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> From: =?iso-8859-15?Q?Rafael_Garc=EDa?= <rafael AT geninfor DOT com>
> Newsgroups: comp.os.msdos.djgpp
> Date: Thu, 30 Oct 2003 14:07:52 +0100
> 
> I thought type double had at least 15 decimal digits of precision

It does.

> but I have found I can get a result with only 13 precise digits. Can
> anyone please explain that result?

This is expected, since

   a - b = a*(1 - b/a)

and, for the case in point, where a and b are close to each other and
thus b/a is on the order of magnitude of one, the precision of this
expression is |a|*10^(-16).  |a| is 4*10^3, so you get 10^(-13) of
absolute pecision.

In other words, this happens because the precision of FP arithmetics
is 10^(-16) relative to the magnitude of the original operands.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019