Bug report
Bug description:
As an example:
>>> import math
>>> n = math.atan2(-1.0, 4503599627370496.0)
>>> k = 2 * math.pi
>>> n
-2.220446049250313e-16
>>> k
6.283185307179586
>>> n % k
6.283185307179586
>>> n % k % k
0.0
>>>
This looks to be due to:
|
mod = fmod(vx, wx); |
|
if (mod) { |
|
/* ensure the remainder has the same sign as the denominator */ |
|
if ((wx < 0) != (mod < 0)) { |
|
mod += wx; |
|
} |
|
} |
On the first modulo we have
mod < 0 but
mod + wx == wx, so
n % k == k, and then on the second modulo we have
fmod(wx, wx) == 0, so
n % k % k == 0.
CPython versions tested on:
3.12
Operating systems tested on:
Linux
Bug report
Bug description:
As an example:
This looks to be due to:
cpython/Objects/floatobject.c
Lines 619 to 625 in 569fc68
On the first modulo we have
mod < 0butmod + wx == wx, son % k == k, and then on the second modulo we havefmod(wx, wx) == 0, son % k % k == 0.CPython versions tested on:
3.12
Operating systems tested on:
Linux