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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: border1.nntp.dca1.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!1.eu.feeder.erje.net!weretis.net!feeder4.news.weretis.net!news.mixmin.net!aioe.org!.POSTED!not-for-mail From: "Nasser M. Abbasi" Newsgroups: comp.lang.ada Subject: Re: getting same output as gfortran, long_float Date: Fri, 01 May 2015 12:27:27 -0500 Organization: Aioe.org NNTP Server Message-ID: References: Reply-To: nma@12000.org NNTP-Posting-Host: CV72NQ0GT7rQd8cP1ZYi/A.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: number.nntp.giganews.com comp.lang.ada:192995 Date: 2015-05-01T12:27:27-05:00 List-Id: 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. You are right. --Nasser