mirror of
https://github.com/micropython/micropython.git
synced 2026-01-08 05:00:26 +01:00
Fixed modulo operator on ints and mp ints to agree with python. Added intdivmod.c and tests/basics/modulo.py.
This commit is contained in:
23
tests/basics/modulo.py
Normal file
23
tests/basics/modulo.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# check modulo matches python definition
|
||||
|
||||
print(123 % 7)
|
||||
print(-123 % 7)
|
||||
print(123 % -7)
|
||||
print(-123 % -7)
|
||||
|
||||
a = 321
|
||||
b = 19
|
||||
|
||||
print(a % b)
|
||||
print(a % -b)
|
||||
print(-a % b)
|
||||
print(-a % -b)
|
||||
|
||||
|
||||
a = 987654321987987987987987987987
|
||||
b = 19
|
||||
|
||||
print(a % b)
|
||||
print(a % -b)
|
||||
print(-a % b)
|
||||
print(-a % -b)
|
||||
Reference in New Issue
Block a user