Using MATLAB: Why does 1-eps == 1-eps*4/3
return FALSE
. With M mantissa bits, shouldn't eps*4/3
be 1.0101...*2^-M which will be rounded to eps
when subtracted from 1?
Asked
Active
Viewed 227 times
2

bnorm
- 399
- 2
- 16
-
No. Try examining `eps` and `eps*4/3`. You'll see that they're unequal. Besides which `eps` gives you the maximum floating point error expected between a real number (i.e. with as many bits of precision as possible) and one stored on a computer. Also, in MATLAB, `eps = 2^-52`, so doing `eps*4/3 = (4/3)*2^-52` and that's also why the equality doesn't hold. – rayryeng Oct 28 '15 at 03:45
-
1@rayryeng I get that `eps` and `eps*4/3` aren't equal by themselves, but I though when they were both subtracted from 1 the `eps*4/3` wouldn't be able to maintain accuracy. Also then, why does `1-eps/2 == 1-eps*4/3` hold? I though with M bits `eps` could not be rounded to fractions? – bnorm Oct 28 '15 at 04:02
-
I think rounding point is not first bit. After typing 'format hex' on matlab window, I check 'eps*(4/3)', Answer was '3cb5555555555555', but when I tried 'eps*(5/4)', the answer was '3cb4000000000000'. and '1-eps*(5/4)==1-eps' is true. – KKS Oct 28 '15 at 04:23
-
1You aren't going small enough. This works: `1e-323 == 9.8813e-324`. – Dev-iL Oct 28 '15 at 09:06
-
But `1+eps == 1+ 4/3*(eps)` returns true.. – Steve Oct 28 '15 at 14:18