Damien George
10 years ago
4 changed files with 34 additions and 35 deletions
@ -0,0 +1,21 @@ |
|||
# test integer floor division and modulo |
|||
|
|||
# test all combination of +/-/0 cases |
|||
for i in range(-2, 3): |
|||
for j in range(-4, 5): |
|||
if j != 0: |
|||
print(i, j, i // j, i % j, divmod(i, j)) |
|||
|
|||
# this tests compiler constant folding |
|||
print(123 // 7, 123 % 7) |
|||
print(-123 // 7, -123 % 7) |
|||
print(123 // -7, 123 % -7) |
|||
print(-123 // -7, -123 % -7) |
|||
|
|||
# this tests bignum modulo |
|||
a = 987654321987987987987987987987 |
|||
b = 19 |
|||
print(a % b) |
|||
print(a % -b) |
|||
print(-a % b) |
|||
print(-a % -b) |
@ -1,23 +0,0 @@ |
|||
# check modulo matches python definition |
|||
|
|||
# this tests compiler constant folding |
|||
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) |
Loading…
Reference in new issue