skulpt / skulpt

Skulpt is a Javascript implementation of the Python programming language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

% operator incorrect for large negative integers

s-cork opened this issue · comments

commented

e.g.

>>> x = -int('1' * 100)
>>> x%4
# skulpt says -3
1

This is because of the difference between the % operator in javascript vs python
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Remainder

It shouldn't be too difficult to fix.
Inside the scope of a related pr might be to add test_long.py from cpython (we don't currently include it)
Adding it will likely expose some other int related bugs 😬