-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Closed as not planned
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
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:
Lines 619 to 625 in 569fc68
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
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error