float2Int seems to overflow somewhere between 2^^62 and 2^^63 for 64-bit machines (I tried it on intel iMac with GHC 7.6.1). I just noticed this issue when trying to check the maxBound for Int. float2Int is implemented as a primop float2Int# in GHC.
GHCi Prompt output is below - maxBound::Int is 2^^63 on my intel mac. I also tried casting 2^^63 to Float, and then reducing the values a bit to see if the overflow goes away (to account for small rounding errors if any). It doesn't:
λ: maxBound :: Int
9223372036854775807
λ: GHC.Float.float2Int $ 2^^63 -- overflows
-9223372036854775808
λ: GHC.Float.float2Int $ (9223372036854775807::Float) -- now try actual value of 2^^63
-9223372036854775808
λ: GHC.Float.float2Int $ (9223372036854000000::Float) -- reduce it a bit
-9223372036854775808
λ: minBound :: Int -- overflow value is same as minBound::Int
-9223372036854775808
λ: GHC.Float.float2Int $ 2^^62 + 2^^61 -- works fine here
6917529027641081856
Is this overflow on 64-bit Int boundary an expected behavior? It seems to work fine until 2^^62, and overflows somewhere between 2^^62 and 2^^63. I looked up GHC trac to see if there were any reported bugs, and didn't find any. I didn't find any posts on SO either about this one.