From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, PDS_BTC_ID autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Thread: 103376,1525d71e3169ed06 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!proxad.net!usenet-fr.net!enst.fr!melchior!cuivre.fr.eu.org!melchior.frmug.org!not-for-mail From: "David C. Hoos" Newsgroups: comp.lang.ada Subject: Re: Float precision - gnat vs objectada Date: Wed, 1 Dec 2004 12:50:34 -0600 Organization: Cuivre, Argent, Or Message-ID: References: <1c8dc73c.0412010746.272b978@posting.google.com> NNTP-Posting-Host: lovelace.ada-france.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: melchior.cuivre.fr.eu.org 1101927075 56769 212.85.156.195 (1 Dec 2004 18:51:15 GMT) X-Complaints-To: usenet@melchior.cuivre.fr.eu.org NNTP-Posting-Date: Wed, 1 Dec 2004 18:51:15 +0000 (UTC) Cc: "comp.lang.ada@ada.eu.org" To: "P Torle" Return-Path: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at ada-france.org X-BeenThere: comp.lang.ada@ada-france.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Gateway to the comp.lang.ada Usenet newsgroup" List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: g2news1.google.com comp.lang.ada:6696 Date: 2004-12-01T12:50:34-06:00 Anything beyond 3.14159_26535_89793 is lost when storing the value in the 64-bit floating point variable, because there is room for only 53 bits of mantissa. To generate more than 15 significant digits requires extending the mantissa with binary zeroes, which of course are not accurate. Both compilers appear to have done a little of that -- gnat to a reasonable extent, and ObjectAda to an unreasonable extent. If your program had called for Aft = 14, or even 15, the results would have been identical. Note that the 16th digit after the decimal point is wrong from _both_ compilers, compared to the true value. However to expect the 16th and subsequent digits after the decimal point from _any_ compiler, given a 53-bit mantissa is unreasonable. ----- Original Message ----- From: "P Torle" Newsgroups: comp.lang.ada To: Sent: Wednesday, December 01, 2004 9:46 AM Subject: Float precision - gnat vs objectada > I'm working on a Ada95/C project that shall run on both Linux and > Windows. > I have some problems getting the same float precision on both > platforms. > Example: > ----------------------------- > subtype Real is Long_Float; > pi : Real; > > pi := 3.14159_26535_89793_23846_26433_83279_50288_41971_69399_37511; > Real_Io.Put(pi, Aft => 25); > ----------------------------- > > Results: > Linux: 3.1415926535897931200000000E+00 > Win32: 3.1415926535897931159979634E+00 > > The thing is, the following float-precision definitions are equal on > both Linux and Windows: > > Real'Machine_Mantissa : 53 > Real'Machine_Emin : -1021 > Real'Machine_Emax : 1024 > Real'Digits : 15 > > So why the difference? > > The Windows code is built with ObjectAda/adacomp and Microsoft tools > cl.exe/link.exe. > The Linux code is built with gnat/gcc 3.4.2 > _______________________________________________ > comp.lang.ada mailing list > comp.lang.ada@ada-france.org > http://www.ada-france.org/mailman/listinfo/comp.lang.ada >