Description
The current __mod__ implementation for all float types uses LLVM's frem instruction, which computes the IEEE 754 remainder (truncated toward zero). However, __floordiv__ is implemented as floor(a / b), which follows Python's floored division semantics. This mismatch causes the fundamental identity (a // b) * b + (a % b) == a to break when negative numbers are involved.
Example
a = -1.0
b = 3.0
print(a % b) # Codon outputs: -1.0, expected (Python): 2.0
print(a // b) # Codon outputs: -1.0, which is correct
Description
The current
__mod__implementation for all float types uses LLVM'sfreminstruction, which computes the IEEE 754 remainder (truncated toward zero). However,__floordiv__is implemented asfloor(a / b), which follows Python's floored division semantics. This mismatch causes the fundamental identity(a // b) * b + (a % b) == ato break when negative numbers are involved.Example