approxRational is wrong when (rat - eps) overflows in negative direction
This program is wrong. The second output should be 0 % 1.
import Data.Ratio
main = do
print (approxRational (0 % 1 :: Ratio Int) (1 % 10)) -- 0%1, correct
print (approxRational (0 % 1 :: Ratio Word) (1 % 10)) -- 1%1, incorrect
The problem is that (rat-eps) overflows in the negative direction (see source).
Trac metadata
| Trac field | Value |
|---|---|
| Version | 8.2.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | libraries/base |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |