fixed

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

commit a83f75c909a951baa219c35ae682b63b3fd8a3f8
parent f2c8f595c79569338bce841103950dfe7b051f28
Author: Jared Tobin <jared@jtobin.io>
Date:   Wed, 29 Jan 2025 17:35:00 +0400

lib: fix underallocation

Diffstat:
Mlib/Data/Word/Extended.hs | 5+++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/Data/Word/Extended.hs b/lib/Data/Word/Extended.hs @@ -833,12 +833,13 @@ div u@(Word256 u0 u1 u2 u3) d@(Word256 d0 _ _ _) -- allocate quotient quo <- PA.newPrimArray 4 PA.setPrimArray quo 0 4 0 - -- allocate dividend - u_arr <- PA.newPrimArray 4 + -- allocate dividend, leaving enough space for normalization + u_arr <- PA.newPrimArray 5 PA.writePrimArray u_arr 0 u0 PA.writePrimArray u_arr 1 u1 PA.writePrimArray u_arr 2 u2 PA.writePrimArray u_arr 3 u3 + -- last index of u_hot intentionally unset _ <- quotrem quo u_arr d q0 <- PA.readPrimArray quo 0 q1 <- PA.readPrimArray quo 1