fixed

Pure Haskell large fixed-width integers.
git clone git://git.ppad.tech/fixed.git
Log | Files | Refs | README | LICENSE

commit 87c28f17c8d5ca7e73f44b4f47de2f10c92d6562
parent 73eca8c98fb444609b725a557eb4406b943132de
Author: Jared Tobin <jared@jtobin.io>
Date:   Sun, 30 Nov 2025 12:57:18 +0400

limb: input mask on sub, return mask

Diffstat:
Mlib/Data/Word/Limb.hs | 6++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/Data/Word/Limb.hs b/lib/Data/Word/Limb.hs @@ -300,8 +300,10 @@ sub_b# -> Limb -- ^ subtrahend -> Limb -- ^ borrow -> (# Limb, Limb #) -- ^ (# difference, new borrow #) -sub_b# (Limb m) (Limb n) (Limb b) = - let !(# d0, b0 #) = Exts.subWordC# m n +sub_b# (Limb m) (Limb n) (Limb a) = + let !s = case B.finiteBitSize (0 :: Word) of Exts.I# bs -> bs Exts.-# 1# + !b = Exts.uncheckedShiftRL# a s + !(# d0, b0 #) = Exts.subWordC# m n !(# d, b1 #) = Exts.subWordC# d0 b !c = Exts.int2Word# (Exts.negateInt# (Exts.orI# b0 b1)) in (# Limb d, Limb c #)