|
"Petr Krysl" <pkryslNOSP@Mucsd.edu> wrote in message <h4bbvq$p3a$1@fred.mathworks.com>...
> Here's something to think about for all the curious people out there:
>
> >> 1==1+0.5000000000000001*eps(1)
>
> ans =
>
> 0
>
> >> 1==1+0.50000000000000001*eps(1)
>
> ans =
>
> 1
>
> We are told in the Matlab documentation that "eps returns the distance from 1.0
> to the next largest double-precision number, that is eps = 2^(-52)." Compare that with the above computations carried out in Matlab 7.5.
>
> Any ideas?
Double precision does not have enough precision to hold the 2nd constant small bit, so calculations round differently. e.g.,
>> format hex
>> 0.5000000000000001
ans =
3fe0000000000001
>> 0.5000000000000001*eps(1)
ans =
3ca0000000000001
>> 1+0.5000000000000001*eps(1)
ans =
3ff0000000000001
>> 0.50000000000000001
ans =
3fe0000000000000
>> 0.50000000000000001*eps(1)
ans =
3ca0000000000000
>> 1+0.50000000000000001*eps(1)
ans =
3ff0000000000000
>> 1
ans =
3ff0000000000000
There are a gazillion such examples one can construct with floating point arithmetic. No big deal.
James Tursa
|