comp.lang.ada
 help / color / mirror / Atom feed
From: "Nasser M. Abbasi" <nma@12000.org>
Subject: Re: getting same output as gfortran, long_float
Date: Fri, 01 May 2015 12:27:27 -0500
Date: 2015-05-01T12:27:27-05:00	[thread overview]
Message-ID: <mi0d1s$m8o$1@speranza.aioe.org> (raw)
In-Reply-To: mi06nf$aih$1@z-news2.pwr.wroc.pl

On 5/1/2015 10:39 AM, Waldek Hebisch wrote:
> Nasser M. Abbasi <nma@12000.org> 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


  reply	other threads:[~2015-05-01 17:27 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-30 21:17 getting same output as gfortran, long_float Nasser M. Abbasi
2015-04-30 22:08 ` Dmitry A. Kazakov
2015-04-30 22:11   ` Dmitry A. Kazakov
2015-04-30 22:37   ` Nasser M. Abbasi
2015-04-30 22:53     ` Nasser M. Abbasi
2015-05-01  7:22       ` Jacob Sparre Andersen
2015-05-01  1:12   ` Nasser M. Abbasi
2015-05-01  6:52     ` Dmitry A. Kazakov
2015-05-01  7:32       ` Nasser M. Abbasi
2015-05-01  7:45         ` Dmitry A. Kazakov
2015-05-04  0:15           ` robin.vowels
2015-05-04  7:21             ` Dmitry A. Kazakov
2015-05-04  8:53               ` robin.vowels
2015-05-04 10:18                 ` Dmitry A. Kazakov
2015-05-04 13:45                   ` robin.vowels
2015-05-04 14:47                     ` Dmitry A. Kazakov
2015-05-07  2:01                       ` robin.vowels
2015-05-01 23:24       ` Dennis Lee Bieber
2015-05-04  0:09       ` robin.vowels
2015-05-01  7:01     ` Dmitry A. Kazakov
2015-05-04  0:42     ` robin.vowels
2015-04-30 22:12 ` Jeffrey R. Carter
2015-04-30 22:27   ` Qun-Ying
2015-05-01  0:59     ` Dennis Lee Bieber
2015-04-30 22:32   ` Nasser M. Abbasi
2015-05-01  1:16     ` Jeffrey R. Carter
2015-05-01  1:40       ` Nasser M. Abbasi
2015-05-01  7:47         ` Jacob Sparre Andersen
2015-05-01 15:39         ` Waldek Hebisch
2015-05-01 17:27           ` Nasser M. Abbasi [this message]
2015-05-01 18:03             ` Nasser M. Abbasi
2015-05-04  0:51             ` robin.vowels
2015-05-04  0:47         ` robin.vowels
2015-05-01  8:21 ` Simon Wright
2015-05-01 11:55 ` Georg Bauhaus
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox