Skip to content

Data.Fixed.mod' sometimes produces nonsensical results

Summary

Prelude Data.Fixed> (-3e19) `mod'` 1.4
-4096.0
Prelude Data.Fixed> 4.9098418106168856e20 `mod'` (-43.4678352235136)
65536.0
Prelude Data.Fixed> (-10) `mod'` exp (-43)
-1.7763568394002505e-15

Expected behavior

My understanding is that mod' should yield a result whose absolute value is smaller than the absolute value of the divisor and which is positive when the divisor is positive.

The fact that some of the above results happen to be powers of 2 is also curious.

Environment

  • GHC version used:

8.6.5

Edited by Roman Cheplyaka
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information