Fix formatting of negative numbers
This commit is contained in:
parent
f415595a40
commit
d082bc939e
1 changed files with 3 additions and 3 deletions
|
|
@ -33,12 +33,12 @@ toDec = T.pack . show
|
||||||
toHex :: (Integral a, Show a) => a -> T.Text
|
toHex :: (Integral a, Show a) => a -> T.Text
|
||||||
toHex a = T.pack $ showHex a ""
|
toHex a = T.pack $ showHex a ""
|
||||||
|
|
||||||
-- | @'negative' a@ interprets @a@ as @a - 'maxBound'@ if @a@ is greater than
|
-- | @'negative' a@ interprets @a@ as @a - 'maxBound' - 1@ if @a@ is greater
|
||||||
-- @'maxBound' `div` 2@, and as a positive number otherwise. 'minBound' is
|
-- than @'maxBound' `div` 2@, and as a positive number otherwise. 'minBound' is
|
||||||
-- ignored.
|
-- ignored.
|
||||||
negative :: (Integral a, Bounded a, Show a) => (a -> T.Text) -> a -> T.Text
|
negative :: (Integral a, Bounded a, Show a) => (a -> T.Text) -> a -> T.Text
|
||||||
negative f a
|
negative f a
|
||||||
| a > maxBound `div` 2 = "-" <> f (-(a - maxBound))
|
| a > maxBound `div` 2 = "-" <> f (-(a - maxBound - 1))
|
||||||
| otherwise = f a
|
| otherwise = f a
|
||||||
|
|
||||||
chunkedBy :: T.Text -> Int -> T.Text -> T.Text
|
chunkedBy :: T.Text -> Int -> T.Text -> T.Text
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue