Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialTana Guşita
190 PointsI 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.....?
2 Answers
Steven Parker
231,269 PointsIt's different, but it's also an example of how small errors will appear in floating-point calculations.
Hambone F
3,581 PointsInterestingly - 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
>>>