zserio
zserio copied to clipboard
Wrong Python float division
The Python emitter currently uses floor division operator '//' regardless of the operand types.
Example:
5 // 2 = 2 (correct)
5.0 // 2 = 2.0 (wrong!)
It will be necessary to fix Python emitter to check the operand types and to use both division operators ('/' or '//').
Please be careful to Python division operator for negative numbers:
3 // 2 = 1
-3 // 2 = -2
Because of that we should probably consider to use something like
(int)(-3 / 2) = -1
Because of that, modulo operator in Python gives different results compared to Java/C++.