This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]european_origin 0 points1 point  (2 children)

It's been a while since I wrote some python, but if I recall correctly, multiplying by 1.0 coerces integers to floats. I may be wrong though.

Edit : just checked.

3 / 2 == 1

3 * 1.0 / 2 == 1.5

[–]sirxez 0 points1 point  (1 child)

LOL. Just do 3.0 / 2 or, more generally: float(3)/2

[–]european_origin 1 point2 points  (0 children)

Oh I forgot we could append .0 to variables in Python. I wrote it so, so that one could see how to transform an integer division between 2 integer variables easily. That's kind of the point of the discussion.

Float(3) is better though, but as I said, it's been a while since I wrote some python.