Js2Py
Js2Py copied to clipboard
JS math func error
when i run eval("Math.round(.5) + ~~1.8") in JS Console , the result is 2
but when i run in Python Console, the result is 1
Had the same issue with Math.round(52.5).
https://docs.python.org/3/library/functions.html#round
rounding is done toward the even choice
https://github.com/PiotrDabkowski/Js2Py/blob/2e017b86e2f18a6c8a842293b1687f2ce7baa12e/js2py/constructors/jsmath.py#L83
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round
If the fractional portion is exactly 0.5, the argument is rounded to the next integer in the direction of +∞.