I am having a bit of trouble understanding how the precision of these doubles affects the outcome of arithmetic operations in Matlab. I thought that since both a & b are doubles they would be able to carry out operations up to that precision. I realize there can be round-off error but since these numbers are well within the 64-bit number representation I didn't think that would be an issue.
a = 1.22e-45
b = 1
a == 0
ans = 0 %a is not equal to zero
(a + b) == 1
ans = 1
How come it is able to carry enough precision to recognize a != 0 but when added to 1 it doesn't show any change.
64-bit IEEE-754 floating point numbers have enough precision (with a 53 bit mantissa) to represent about 16 significant decimal digits. But it requires more like 45 significant decimal digits to tell the difference between (1+a) = 1.00....000122 and 1.000 for your example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With