Data.Fixed truncates 5.17 to 5.16
(realToFrac (5.17 :: Double) :: Centi) == 5.16
is true -- it should be false.
The offender seems to be the assumption in fromRational:
fromRational r = withResolution (\res -> MkFixed (floor (r * (toRational res))))
Uses floor assuming that the underlying floating point value is stored purely and not as 0.999999 or similar -- switching it to round fixes this issue.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 7.6.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | libraries/base |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | ekmett, hvr |
| Operating system | |
| Architecture |