Z-Data-0.1.0.0: array, vector and text
Copyright(c) Dong Han 2017-2019
LicenseBSD
Maintainerwinterland1989@gmail.com
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Z.Data.Builder.Numeric

Description

Textual numeric builders.

Synopsis

Integral type formatting

data IFormat Source #

Integral formatting options.

Constructors

IFormat 

Fields

Instances

Instances details
Eq IFormat Source # 
Instance details

Defined in Z.Data.Builder.Numeric

Methods

(==) :: IFormat -> IFormat -> Bool #

(/=) :: IFormat -> IFormat -> Bool #

Ord IFormat Source # 
Instance details

Defined in Z.Data.Builder.Numeric

Show IFormat Source # 
Instance details

Defined in Z.Data.Builder.Numeric

Arbitrary IFormat Source # 
Instance details

Defined in Z.Data.Builder.Numeric

Methods

arbitrary :: Gen IFormat

shrink :: IFormat -> [IFormat]

CoArbitrary IFormat Source # 
Instance details

Defined in Z.Data.Builder.Numeric

Methods

coarbitrary :: IFormat -> Gen b -> Gen b

defaultIFormat :: IFormat Source #

defaultIFormat = IFormat 0 NoPadding False

data Padding Source #

Instances

Instances details
Enum Padding Source # 
Instance details

Defined in Z.Data.Builder.Numeric

Eq Padding Source # 
Instance details

Defined in Z.Data.Builder.Numeric

Methods

(==) :: Padding -> Padding -> Bool #

(/=) :: Padding -> Padding -> Bool #

Ord Padding Source # 
Instance details

Defined in Z.Data.Builder.Numeric

Show Padding Source # 
Instance details

Defined in Z.Data.Builder.Numeric

Arbitrary Padding Source # 
Instance details

Defined in Z.Data.Builder.Numeric

Methods

arbitrary :: Gen Padding

shrink :: Padding -> [Padding]

CoArbitrary Padding Source # 
Instance details

Defined in Z.Data.Builder.Numeric

Methods

coarbitrary :: Padding -> Gen b -> Gen b

int :: (Integral a, Bounded a) => a -> Builder () Source #

int = intWith defaultIFormat

intWith :: (Integral a, Bounded a) => IFormat -> a -> Builder () Source #

Format a Bounded Integral type like Int or Word16 into decimal ASCII digits.

integer :: Integer -> Builder () Source #

Format a Integer into decimal ASCII digits.

Fixded size hexidecimal formatting

hex :: forall a. (FiniteBits a, Integral a) => a -> Builder () Source #

Format a FiniteBits Integral type into hex nibbles.

heX :: forall a. (FiniteBits a, Integral a) => a -> Builder () Source #

The UPPERCASED version of hex.

IEEE float formating

data FFormat Source #

Control the rendering of floating point numbers.

Constructors

Exponent

Scientific notation (e.g. 2.3e123).

Fixed

Standard decimal notation.

Generic

Use decimal notation for values between 0.1 and 9,999,999, and scientific notation otherwise.

double :: Double -> Builder () Source #

Decimal encoding of an IEEE Double.

Using standard decimal notation for arguments whose absolute value lies between 0.1 and 9,999,999, and scientific notation otherwise.

doubleWith Source #

Arguments

:: FFormat 
-> Maybe Int

Number of decimal places to render.

-> Double 
-> Builder () 

Format double-precision float using drisu3 with dragon4 fallback.

float :: Float -> Builder () Source #

Decimal encoding of an IEEE Float.

Using standard decimal notation for arguments whose absolute value lies between 0.1 and 9,999,999, and scientific notation otherwise.

floatWith Source #

Arguments

:: FFormat 
-> Maybe Int

Number of decimal places to render.

-> Float 
-> Builder () 

Format single-precision float using drisu3 with dragon4 fallback.

scientific :: Scientific -> Builder () Source #

A Builder which renders a scientific number to full precision, using standard decimal notation for arguments whose absolute value lies between 0.1 and 9,999,999, and scientific notation otherwise.

scientificWith Source #

Arguments

:: FFormat 
-> Maybe Int

Number of decimal places to render.

-> Scientific 
-> Builder () 

Like scientific but provides rendering options.

Misc

grisu3 :: Double -> ([Int], Int) Source #

Decimal encoding of a Double, note grisu only handles strictly positive finite numbers.

grisu3_sp :: Float -> ([Int], Int) Source #

Decimal encoding of a Float, note grisu3_sp only handles strictly positive finite numbers.

i2wDec :: Integral a => a -> Word8 Source #

Decimal digit to ASCII digit.

i2wHex :: Integral a => a -> Word8 Source #

Hexadecimal digit to ASCII char.

i2wHeX :: Integral a => a -> Word8 Source #

Hexadecimal digit to UPPERCASED ASCII char.

countDigits :: Integral a => a -> Int Source #

Count how many decimal digits an integer has.

c_intWith :: (Integral a, Bits a) => IFormat -> a -> Builder () Source #

Internal formatting backed by C FFI, it must be used with type smaller than Word64.

We use rewrite rules to rewrite most of the integral types formatting to this function.

hs_intWith :: (Integral a, Bounded a) => IFormat -> a -> Builder () Source #

Internal formatting in haskell, it can be used with any bounded integral type.

Other than provide fallback for the c version, this function is also used to check the c version's formatting result.