Commit b689f3db authored by Sylvain Henry's avatar Sylvain Henry Committed by Marge Bot

Bignum: add clamping naturalToWord (fix #18697)

parent 7f2785f2
......@@ -107,6 +107,14 @@ naturalToWord# (NB b) = bigNatIndex# b 0#
naturalToWord :: Natural -> Word
naturalToWord !n = W# (naturalToWord# n)
-- | Convert a Natural into a Word# clamping to (maxBound :: Word#).
naturalToWordClamp# :: Natural -> Word#
naturalToWordClamp# (NS x) = x
naturalToWordClamp# (NB _) = WORD_MAXBOUND##
-- | Convert a Natural into a Word# clamping to (maxBound :: Word).
naturalToWordClamp :: Natural -> Word
naturalToWordClamp !n = W# (naturalToWordClamp# n)
-- | Try downcasting 'Natural' to 'Word' value.
-- Returns '()' if value doesn't fit in 'Word'.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment