Can somebody explain this to me? I was trying to normalize a set of numbers from -100 to 0 to a range of 10-100 and was having problems only to notice that even with no variables at all, this does not evaluate the way I would expect it to:
>>> (20-10) / (100-10)
0
EDIT: float division doesn't work either:
>>> float((20-10) / (100-10))
0.0
EDIT: right side typing ... who'd have thunk. This is what's happening:
>>> (20-10) / float((100-10))
0.1111111111111111
Each side in the first example is evaluating as an int which means the final answer will be cast to an int. Since 0.111 is less than .5, it rounds to 0. Not transparent in my opinion but I guess that's the way it is.