| delorie.com/archives/browse.cgi | search |
| X-Authentication-Warning: | delorie.com: mail set sender to djgpp-bounces using -f |
| Date: | Thu, 30 Oct 2003 08:25:52 -0500 |
| Message-Id: | <200310301325.h9UDPqVF020025@envy.delorie.com> |
| From: | DJ Delorie <dj AT delorie DOT com> |
| To: | djgpp AT delorie DOT com |
| 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> |
| Errors-To: | nobody AT delorie DOT com |
| X-Mailing-List: | djgpp AT delorie DOT com |
| X-Unsubscribes-To: | listserv AT delorie DOT com |
In this case, the problem is that the two numbers you are subtracting
only have a certain precision *after the decimal*. The result has
the same number of digits after the decimal as the numbers you start with.
Garbage in, garbage out - try printing them like this:
printf("%25.18f\n%25.18f\n%25.18f\n",a,b,c);
You'll see:
4777.909999999999854481
4782.979999999999563443
-5.069999999999708962
Note that the 9's all end in the same column.
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |