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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.52.127.8 with SMTP id nc8mr36570201vdb.1.1430700718144; Sun, 03 May 2015 17:51:58 -0700 (PDT) X-Received: by 10.50.82.8 with SMTP id e8mr106605igy.7.1430700718105; Sun, 03 May 2015 17:51:58 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!z60no4908406qgd.0!news-out.google.com!n7ni24247igk.0!nntp.google.com!l13no13497751iga.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 3 May 2015 17:51:57 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=123.2.70.40; posting-account=S_MdrwoAAAD7T2pxG2e393dk6y0tc0Le NNTP-Posting-Host: 123.2.70.40 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: getting same output as gfortran, long_float From: robin.vowels@gmail.com Injection-Date: Mon, 04 May 2015 00:51:58 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: news.eternal-september.org comp.lang.ada:25717 Date: 2015-05-03T17:51:57-07:00 List-Id: On Saturday, May 2, 2015 at 3:27:29 AM UTC+10, Nasser M. Abbasi wrote: > On 5/1/2015 10:39 AM, Waldek Hebisch wrote: > > Nasser M. Abbasi wrote: > >> > >> Thanks, this is very useful. I noticed small difference in output: > >> side-by-side: > >> > >> Ada: 0.00182898948331047096479195244627343392775491540.. > >> Mathematica*: 0.00182898948331047096479195244627343392775491540.. > >> gfortran: 0.00182898948331047112025871115292829927 > >> > >> at digit 18, gfortran result is different. But your Ada rational > >> package gives same result as Mathematica. This tells me your > >> result is the accurate one ! > > > > Your previous gfortran result was: > > > > 1.82898948331047096479195244627343369E-3 > > > > which agrees with others... > > > > Thanks. My mistake. So the command line flag was needed after all!! > > >gfortran -Wall -fdefault-real-8 foo2.f90 > >./a.out > 1.82898948331047096479195244627343369E-0003 > > Without the flag, the digit is different > > >gfortran -Wall foo2.f90 > >./a.out > 1.82898948331047112025871115292829927E-0003 > > as you say, this is due to D0 in code using double, while > the result "x" is quad. With the flag in, gfortran will > treate all doubles as "quad", hence the correct result. > > I thought with -Wall it will catch all these things, but I think > I need more flags to detect this user error > > >> for reference: > >> > >> ------------------- > >> PROGRAM foo > >> IMPLICIT NONE > >> REAL(KIND = 16) :: x !-- kind=16 tells it is double quad > >> x = 12.0D0 * 0.0001D0/(1.0D0 * (1.0D0 - 0.1D0)**4 ) > >> PRINT *, x > >> END PROGRAM > > > > AFAICS you have 34 digit x, but 17 digit constants. So > > it seems that you assign 17 digit number to x, no > > wonder there is no gain in accuracy. > > > > Yes, needed the command line flag. Not really. he correct way is to specify quad precision constants, e.g., 0.0001_quad