mirror of
https://github.com/micropython/micropython.git
synced 2025-09-06 01:40:34 +02:00
When DIG_SIZE=32, a uint32_t is used to store limbs, and no normalisation is needed because the MSB is already set, then there will be left and right shifts (in C) by 32 of a 32-bit variable, leading to undefined behaviour. This patch fixes this bug.
18 lines
589 B
Python
18 lines
589 B
Python
# test % operation on big integers
|
|
|
|
delta = 100000000000000000000000000000012345
|
|
|
|
for i in range(11):
|
|
for j in range(11):
|
|
x = delta * (i)# - 5) # TODO reinstate negative number test when % is working with sign correctly
|
|
y = delta * (j)# - 5) # TODO reinstate negative number test when % is working with sign correctly
|
|
if y != 0:
|
|
print(x % y)
|
|
|
|
# these check an edge case on 64-bit machines where two mpz limbs
|
|
# are used and the most significant one has the MSB set
|
|
x = 0x8000000000000000
|
|
print((x + 1) % x)
|
|
x = 0x86c60128feff5330
|
|
print((x + 1) % x)
|