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.70.48.206 with SMTP id o14mr4192533pdn.1.1430700170010; Sun, 03 May 2015 17:42:50 -0700 (PDT) X-Received: by 10.50.8.7 with SMTP id n7mr106027iga.15.1430700169975; Sun, 03 May 2015 17:42:49 -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!news.glorb.com!l13no13496215iga.0!news-out.google.com!kd3ni7465igb.0!nntp.google.com!l13no13496213iga.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 3 May 2015 17:42:49 -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: <1kxou0nloqg9c$.1x0itzgdrlosm$.dlg@40tude.net> 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:42:49 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: news.eternal-september.org comp.lang.ada:25715 Date: 2015-05-03T17:42:49-07:00 List-Id: On Friday, May 1, 2015 at 11:12:51 AM UTC+10, Nasser M. Abbasi wrote: > On 4/30/2015 5:08 PM, Dmitry A. Kazakov wrote: > > > If GNAT allowed floating-point emulation, you could declare a custom type > > of required precision: > > > > type My_Float is digits 34; -- 112 * lg(2) > > > > Which is advisable anyway in order to make your program portable. Using > > built-in types is a bad idea and poor taste in most cases. > > > > Since GNAT does support emulation, at least not with the standard compiler > > switches, you need a library for doing this. > > > > I found that gfortran can do 128 bit floating point without > the use of the compiler switch -fdefault-real-8. Which will > map to similar thing as the above Ada construct: > > ------------------- > PROGRAM foo > IMPLICIT NONE > REAL(KIND = 16) :: x !-- kind=16 tells it is double quad No it doesn't. That form is non-standard, and won't compile with some compilers. You need to use SELECTED_REAL_KIND or something equivalent. > x = 12.0D0 * 0.0001D0/(1.0D0 * (1.0D0 - 0.1D0)**4 ) And the above constants are double precision, not quadruple precision, to the numerical result with have no more precision than double. > PRINT *, x > END PROGRAM > ------------------ > > gfortran -Wall foo2.f90 > ./a.out > 1.82898948331047112025871115292829927E-0003