[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Possible loss of accuracy
From: |
Sergei Steshenko |
Subject: |
Re: Possible loss of accuracy |
Date: |
Wed, 15 May 2013 10:11:06 -0700 (PDT) |
--- On Wed, 5/15/13, John W. Eaton <address@hidden> wrote:
> From: John W. Eaton <address@hidden>
> Subject: Re: Possible loss of accuracy
> To: "Marco Caliari" <address@hidden>
> Cc: address@hidden, address@hidden
> Date: Wednesday, May 15, 2013, 9:59 AM
> On 05/15/2013 05:27 AM, Marco Caliari
> wrote:
> > Dear all,
> >
> > if I compute
> >
> > t=50
> > (1-2^(-t))^(2^t)
> >
> > I get (different versions, machines, ...)
> >
> > ans = 3.67879441128629e-01
> >
> > which is correct to the 10th digit (compared with
> www.wolframalpha.com).
> > I can stay with it, but Matlab is correct to the 15th
> digit. While
> > trying to understand, I wrote the following Fortran
> code
> >
> > program test
> > integer t
> > t = 50
> > write(6,'(1x,e24.16)') (1.d0-2.d0**(-t))**(2.d0**t)
> > write(6,'(1x,e24.16)') (1.d0-2.d0**(-50))**(2.d0**50)
> > stop
> > end
> >
> > If I compile with gfortran test.f (gfortran 4.3.3) and
> run, I get
> >
> > 0.3678794411286288E+00 (~ Octave value)
> > 0.3678794411714422E+00 (~ Matlab value)
> >
> > and if I compile with gfortran -O2 test.f and run, I
> get
> >
> > 0.3678794411714422E+00
> > 0.3678794411714422E+00
>
> I don't know what the problem is, but with Octave 3.6.2 on
> my system,
> I get 0.367879441171442 for your expression.
>
> jwe
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave
>
IIRC, on x86-64 80 bit FP registers are _not_ used.
Is you machine by any chance a 64 bit one ?
Regards,
Sergei.
Re: Possible loss of accuracy, Sergei Steshenko, 2013/05/16