add word8 and int
This commit is contained in:
parent
b47c1b2ed1
commit
7ed17f5b6d
2 changed files with 29 additions and 0 deletions
|
@ -31,7 +31,9 @@ module Data.ByteArray.Builder
|
|||
, word64Dec
|
||||
, word32Dec
|
||||
, word16Dec
|
||||
, word8Dec
|
||||
, int64Dec
|
||||
, intDec
|
||||
, word64PaddedUpperHex
|
||||
, word32PaddedUpperHex
|
||||
, word16PaddedUpperHex
|
||||
|
@ -271,6 +273,12 @@ word32Dec w = fromBounded Nat.constant (Bounded.word32Dec w)
|
|||
word16Dec :: Word16 -> Builder
|
||||
word16Dec w = fromBounded Nat.constant (Bounded.word16Dec w)
|
||||
|
||||
-- | Encodes an unsigned 8-bit integer as decimal.
|
||||
-- This encoding never starts with a zero unless the
|
||||
-- argument was zero.
|
||||
word8Dec :: Word8 -> Builder
|
||||
word8Dec w = fromBounded Nat.constant (Bounded.word8Dec w)
|
||||
|
||||
-- | Encode a double-floating-point number, using decimal notation or
|
||||
-- scientific notation depending on the magnitude. This has undefined
|
||||
-- behavior when representing @+inf@, @-inf@, and @NaN@. It will not
|
||||
|
@ -285,6 +293,13 @@ doubleDec w = fromBounded Nat.constant (Bounded.doubleDec w)
|
|||
int64Dec :: Int64 -> Builder
|
||||
int64Dec w = fromBounded Nat.constant (Bounded.int64Dec w)
|
||||
|
||||
-- | Encodes a signed machine-sized integer as decimal.
|
||||
-- This encoding never starts with a zero unless the argument was zero.
|
||||
-- Negative numbers are preceded by a minus sign. Positive numbers
|
||||
-- are not preceded by anything.
|
||||
intDec :: Int -> Builder
|
||||
intDec w = fromBounded Nat.constant (Bounded.intDec w)
|
||||
|
||||
-- | Encode a 64-bit unsigned integer as hexadecimal, zero-padding
|
||||
-- the encoding to 16 digits. This uses uppercase for the alphabetical
|
||||
-- digits. For example, this encodes the number 1022 as @00000000000003FE@.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue