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 trialNick Evershed
6,429 Points0.1 + 0.1 + 0.1 - 0.3
Im very confused why this dosent return a 0, instead some crazy exponent
4 Answers
Matt Farrelly
Courses Plus Student 333 PointsIt's do with the way that python stores floating point numbers using binary as a base. More info here: https://docs.python.org/3.3/tutorial/floatingpoint.html
<noob />
17,062 Pointsitβs basic math. it works in python like in real math if u substract something even if itβs below zero it will give back the result of that substraction
Nick Evershed
6,429 Pointswouldn't a calculator give 0?
Shirley C Fletcher
Full Stack JavaScript Techdegree Student 104 Pointswhy we use underscore with round in in this round(_) what is use of underscore how its working with results which is come up which was 5.2334934 e-17 etc can you define how underscore going to be assgined to the up result thanks
Ous Bayaa
411 PointsIs there an answer to this question please?
Tim Albertson
2,823 PointsThe underscore just stores the result of the last expression in the Python Interpreter (REPL) https://hackernoon.com/understanding-the-underscore-of-python-309d1a029edc
In the case of the video lecture, instead of typing the long number, its value was already stored in _, so he used that to save time.
Master ohm
40 Pointswe would use _ , to extract the same value as previously loaded?
tomaszfurmanczyk
Full Stack JavaScript Techdegree Student 18,242 Pointstomaszfurmanczyk
Full Stack JavaScript Techdegree Student 18,242 PointsIts very simple if you were to add 1 + 1 + 1 and then subtract 3 this would give you Zero 0 This is because you are dealing with integers not floats which hold decimals So .01 + .01 is adding two floats together the result is 0.2 However, as soon as you add the third float this gives us a small variance remainder .1 +.1 + .1 = 0.30000000000000004 then we subtract .3 from this and thats why we get the crazy decimal that is almost zero .1 + .1+ .1 - .3 = 5.551115123125783e-17 this actually means .00000000000000005551115123125783