X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f From: =?iso-8859-15?Q?Rafael_Garc=EDa?= Newsgroups: comp.os.msdos.djgpp Subject: double with only 13 digit precision? Date: Thu, 30 Oct 2003 14:07:52 +0100 Organization: Telefonica Data Espagna Lines: 23 Message-ID: NNTP-Posting-Host: 100.red-80-34-252.pooles.rima-tde.net Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15; format=flowed X-Trace: nsnmrro2-gest.nuria.telefonica-data.net 1067519278 21672 80.34.252.100 (30 Oct 2003 13:07:58 GMT) X-Complaints-To: usenet AT nsnmrro2-gest DOT nuria DOT telefonica-data DOT net NNTP-Posting-Date: Thu, 30 Oct 2003 13:07:58 +0000 (UTC) User-Agent: Opera7.11/Win32 M2 build 2887 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com I thought type double had at least 15 decimal digits of precision, but I have found I can get a result with only 13 precise digits. Can anyone please explain that result? Thanks #include int main() { double a=4777.91; double b=4782.98; double c=a-b; printf("%.18g-%.18g=%.18g\n",a,b,c); // show count of significant digits: printf("1234 56789abcdefgXX 1234 56789abcdefgXX 1 23456789abcXXXXXX\n") ; printf(" ^OK ^OK ^Why??\n") ; printf(" 16 digit precision 16 digit precision 13 digit precision\n") ; return 0; }