Finite list becomes infinite after maping fractional function for high numbers
Tested with version 8.2.2 and 8.0.2 (stack lts-11.5, lts-9.21, nightly-2018-04-14) with GHC and GHCi on archlinux amd64.
- *Code that produces wrong results**
map (/2) [9007199254740990..9007199254740991]
- *Expected behaviour**
same as with low values:
map (/2) [5..6]
resulting in:
[2.5,3.0]
- *Actual behaviour**
resulting in an infinite list:
[4.503599627370495e15,4.5035996273704955e15,4.503599627370496e15..]
- *Similar code that produces expected results**
multiplication works:
map (*2) [9007199254740990..9007199254740991]
slightly smaller number work:
map (/2) [9007199254740989..9007199254740990]
using a comma to produce the same list works:
map (/2) [9007199254740990,9007199254740991]
- *Similar code that also produces unexpected results**
more elements in the list:
map (/2) [9007199254740990..9007199254740999]
map (/2) [9007199254740990..9007199354740999]
substituting the number and doing calculations:
map (/2) [9007199254740990..9007199254740990+1]
let a = 9007199254740990
map (/2) [a..a+1]
using scan and fold:
foldl1 (/) [9007199254740990..9007199254740991]
scanl1 (/) [9007199254740990..9007199254740991]
- *Notes**
This somehow only happens with high numbers when using fractional operations and using .. to construct the list.
Trac metadata
Trac field | Value |
---|---|
Version | 8.2.2 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |