on master help sign in
Undo an overflow bug I introduced with quotRem
587f61cBryan O'Sullivan
Data/Text/Lazy/Builder/Int.hs+5−4
@@ -73,12 +73,13 @@ decimal' :: (Integral a) => (a -> Bool) -> a -> Builder
73{-# INLINE decimal' #-}
73{-# INLINE decimal' #-}
74decimal' p i
74decimal' p i
75 | i < 0 = if p i
75 | i < 0 = if p i
76− then let (q, r) = (-i) `quotRem` 10
76+ then let (q, r) = i `quotRem` 10
77+ qq = -q
77− !n = countDigits q
78+ !n = countDigits qq
78 in writeN (n + 2) $ \marr off -> do
79 in writeN (n + 2) $ \marr off -> do
79 unsafeWrite marr off minus
80 unsafeWrite marr off minus
80− posDecimal marr (off+1) n q
81+ posDecimal marr (off+1) n qq
81− unsafeWrite marr (off+n+1) (i2w r)
82+ unsafeWrite marr (off+n+1) (i2w (-r))
82 else let j = -i
83 else let j = -i
83 !n = countDigits j
84 !n = countDigits j
84 in writeN (n + 1) $ \marr off ->
85 in writeN (n + 1) $ \marr off ->