Bugs item #652927, was opened at 2002-12-12 21:24 You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=108032&aid=652927&group_id=8032
Category: hslibs/lang Group: 5.04.2 Status: Open Resolution: None Priority: 5 Submitted By: Mike Gunter (magunter) Assigned to: Nobody/Anonymous (nobody) Summary: Integer -> Int64 sometimes wrong Initial Comment: Conversion from Integer to Int64 values sometimes produces the wrong value. In particular, it seems to fail on small-magnitude negative values whose representation is large. E.g. > (fromIntegral ((2^30 -1 + 2^30) - (2^30 + 2^30 :: Integer))) :: Data.Int.Int64 4294967295 > (fromIntegral ((2^30 - 2 + 2^30) - (2^30 - 1 + 2^30 :: Integer))) :: Data.Int.Int64 -1 The Haskell-level workaround is to do the conversion as a non-negative number then negate if needed: > let fis (i::Integer) = (fromIntegral (signum i) * fromIntegral (abs i)) :: Data.Int.Int64 > fis ((2^30 -1 + 2^30) - (2^30 + 2^30 :: Integer)) -1 ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=108032&aid=652927&group_id=8032 _______________________________________________ Glasgow-haskell-bugs mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
