summaryrefslogtreecommitdiff
path: root/libraries/ghc-bignum
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/ghc-bignum')
-rw-r--r--libraries/ghc-bignum/src/GHC/Num/BigNat.hs10
-rw-r--r--libraries/ghc-bignum/src/GHC/Num/Integer.hs24
2 files changed, 17 insertions, 17 deletions
diff --git a/libraries/ghc-bignum/src/GHC/Num/BigNat.hs b/libraries/ghc-bignum/src/GHC/Num/BigNat.hs
index fa8b84eccd..5fa81b7e5b 100644
--- a/libraries/ghc-bignum/src/GHC/Num/BigNat.hs
+++ b/libraries/ghc-bignum/src/GHC/Num/BigNat.hs
@@ -263,6 +263,16 @@ bigNatToWord64# b
in uncheckedShiftL64# wh 32# `or64#` wl
else wl
+#else
+
+-- | Convert a Word64# into a BigNat on 64-bit architectures
+bigNatFromWord64# :: Word64# -> BigNat#
+bigNatFromWord64# w64 = bigNatFromWord# (word64ToWord# w64)
+
+-- | Convert a BigNat into a Word64# on 64-bit architectures
+bigNatToWord64# :: BigNat# -> Word64#
+bigNatToWord64# b = wordToWord64# (bigNatToWord# b)
+
#endif
-- | Encode (# BigNat mantissa, Int# exponent #) into a Double#
diff --git a/libraries/ghc-bignum/src/GHC/Num/Integer.hs b/libraries/ghc-bignum/src/GHC/Num/Integer.hs
index e2a020619e..d85148fc05 100644
--- a/libraries/ghc-bignum/src/GHC/Num/Integer.hs
+++ b/libraries/ghc-bignum/src/GHC/Num/Integer.hs
@@ -998,14 +998,12 @@ integerIsPowerOf2# (IS i)
integerIsPowerOf2# (IN _) = (# (# #) | #)
integerIsPowerOf2# (IP w) = bigNatIsPowerOf2# w
-#if WORD_SIZE_IN_BITS == 32
-
--- | Convert an Int64# into an Integer on 32-bit architectures
+-- | Convert an Int64# into an Integer
integerFromInt64# :: Int64# -> Integer
{-# NOINLINE integerFromInt64# #-}
integerFromInt64# !i
- | isTrue# ((i `leInt64#` intToInt64# 0x7FFFFFFF#)
- &&# (i `geInt64#` intToInt64# -0x80000000#))
+ | isTrue# ((i `leInt64#` intToInt64# INT_MAXBOUND#)
+ &&# (i `geInt64#` intToInt64# INT_MINBOUND#))
= IS (int64ToInt# i)
| isTrue# (i `geInt64#` intToInt64# 0#)
@@ -1014,37 +1012,29 @@ integerFromInt64# !i
| True
= IN (bigNatFromWord64# (int64ToWord64# (negateInt64# i)))
--- | Convert a Word64# into an Integer on 32-bit architectures
+-- | Convert a Word64# into an Integer
integerFromWord64# :: Word64# -> Integer
{-# NOINLINE integerFromWord64# #-}
integerFromWord64# !w
- | isTrue# (w `leWord64#` wordToWord64# 0x7FFFFFFF##)
+ | isTrue# (w `leWord64#` wordToWord64# INT_MAXBOUND##)
= IS (int64ToInt# (word64ToInt64# w))
| True
= IP (bigNatFromWord64# w)
--- | Convert an Integer into an Int64# on 32-bit architectures
+-- | Convert an Integer into an Int64#
integerToInt64# :: Integer -> Int64#
{-# NOINLINE integerToInt64# #-}
integerToInt64# (IS i) = intToInt64# i
integerToInt64# (IP b) = word64ToInt64# (bigNatToWord64# b)
integerToInt64# (IN b) = negateInt64# (word64ToInt64# (bigNatToWord64# b))
--- | Convert an Integer into a Word64# on 32-bit architectures
+-- | Convert an Integer into a Word64#
integerToWord64# :: Integer -> Word64#
{-# NOINLINE integerToWord64# #-}
integerToWord64# (IS i) = int64ToWord64# (intToInt64# i)
integerToWord64# (IP b) = bigNatToWord64# b
integerToWord64# (IN b) = int64ToWord64# (negateInt64# (word64ToInt64# (bigNatToWord64# b)))
-#else
-
--- | Convert an Int64# into an Integer on 64-bit architectures
-integerFromInt64# :: Int# -> Integer
-integerFromInt64# !x = IS x
-
-#endif
-
----------------------------------------------------------------------------
-- Conversions to/from floating point
----------------------------------------------------------------------------