Welcome to the Treehouse Community
Looking to learn something new?
I tried something different
instead of 0.1+0.1+0.1-0.3 i wrote 0.2+0.2+0.2-0.6 and i got 1.1102230246251565e-16 is it the same as 5.5.....?
Steven Parker216,016 Points
It's different, but it's also an example of how small errors will appear in floating-point calculations.
Hambone F3,569 Points
Interestingly - it's actually exactly twice the 5.5 number seen in the video. It kind of makes sense, double the magnitude of the inputs, double the magnitude of the error.
You can try it right in the REPL:
>>> err1 = 0.1 + 0.1 + 0.1 - 0.3 >>> err1 5.551115123125783e-17 >>> err2 = 0.2 + 0.2 + 0.2 - 0.6 >>> err2 1.1102230246251565e-16 >>> err1 * 2 == err2 True >>>