I assume that when you say does not count 1/2 you actually mean that it results in 0
. That's just standard integer math. When you divide an integer by another integer, the result is also an integer. So, it will result in 0
(because the real answer of 0.5
is not an integer). That's typical of most programming languages.
To get a floating point result, at least one of the numbers must, itself, be a float - as you've discovered.
So, either 1 / 2.0
or 1.0 / 2
will result in the expected answer of 0.5
. So, one or both numbers need to be promoted to a float to get a float answer. You can do that by adding a .0
to at least one of the values, or wrapping it in a float
call like float(1)/2
or 1/float(2)
.
You'll need to do one of those to get a float answer...