Skip to content

truncate /= double2Int

There is a rule in libraries/base/GHC/Float.hs:

"truncate/Double->Int"  truncate = double2Int

But it is not true for some values. Particularly,

let infinity = 1/0 :: Double
truncate infinity :: Int == 0
double2Int infinity == -9223372036854775808  -- minBound

As a result, the value of truncate (1/0 :: Double) :: Int depends on optimization level.

Trac metadata
Trac field Value
Version 7.10.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component libraries/base
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information