1/4
is zero - since both operands are integers, the result is floored to an integer as well. This is the same behavior you're observing earlier with -1/4
.
If you want a non-integer result, one or both of the operands have to be floats. For example:
0 - 1 / 4.to_f
to_f
makes the interpreter interpret the number as a float.
edit: Your calculation is wrong, by the way. 0 - 1/4
is NOT the same as (0-1) / 4
. Always do your operations in the correct order!