on master help sign in
Undo an overflow bug I introduced with quotRem
commit587f61c0546475089f5bb02f527050119996a471 authorBryan O'Sullivan <bos@serpentine.com> dateWed 20 Mar 2013, 13:01 (14 years ago) parent50a3dda
1 file changed+5−4
Data/Text/Lazy/Builder/Int.hs+5−4
Data/Text/Lazy/Builder/Int.hs+5−4
@@ -73,12 +73,13 @@ decimal' :: (Integral a) => (a -> Bool) -> a -> Builder
7373{-# INLINE decimal' #-}
7474decimal' p i
7575 | i < 0 = if p i
76− then let (q, r) = (-i) `quotRem` 10
77− !n = countDigits q
76+ then let (q, r) = i `quotRem` 10
77+ qq = -q
78+ !n = countDigits qq
7879 in writeN (n + 2) $ \marr off -> do
7980 unsafeWrite marr off minus
80− posDecimal marr (off+1) n q
81− unsafeWrite marr (off+n+1) (i2w r)
81+ posDecimal marr (off+1) n qq
82+ unsafeWrite marr (off+n+1) (i2w (-r))
8283 else let j = -i
8384 !n = countDigits j
8485 in writeN (n + 1) $ \marr off ->