Bill Allombert on Fri, 16 Feb 2024 17:09:30 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Numerical instability in extracting base B digits of the fractional part of real


On Fri, Feb 16, 2024 at 05:55:54PM +0200, Georgi Guninski wrote:
> On Fri, Feb 16, 2024 at 1:20 PM Bill Allombert
> <Bill.Allombert@math.u-bordeaux.fr> wrote:
> >
> > ? a=.33
> > %6 = 0.33000000000000000000000000000000000000
> > ? a*10-3
> > %7 = 0.30000000000000000000000000000000000000
> > ? b=a*10-3
> > %8 = 0.30000000000000000000000000000000000000
> > ? b*10-3
> > %9 = -2.350988701644575016E-38
> >
> 
> Thanks. Why I don't see -2.350988701644575016E-38 in my session?
> It must be there, since you unrolled the first two iterations of
> the loop.

Because you continue with A=frac(A), and since A is negative, it is A+1,
so

? frac(b*10-3)
%5 = 0.99999999999999999999999999999999999998

Cheers,
Bill.