razom-text-util-0.1.2.0: Common text/parsing tools for Razom language packages.

Safe HaskellNone
LanguageHaskell2010

Text.Razom.Number

Synopsis

Documentation

isBinDigit :: Char -> Bool Source

Selects ASCII binary digits, i.e. '0' and '1'.

digitsToNum :: Num a => a -> [a] -> a Source

Given the radix and an integer represented as a list of digits, construct a number of the represented value.

>>> digitsToNum 2 [1, 0, 1, 1, 0, 1]
45
>>> digitsToNum 16 [15, 15]
255

binit :: Num a => Regex a Source

octit :: Num a => Regex a Source

digit :: Num a => RE Char a

Decimal digit, i.e. '0'..'9'

octal :: Num a => Regex a Source

decimal :: Num a => RE Char a

Parse decimal number without sign.

hexadecimal :: Num a => RE Char a

Parse decimal number without sign.

signed :: Num a => RE Char a -> RE Char a

Add optional sign

fromDigits :: [Int] -> [Int] -> RealNum Source

Read a decimal number string into a RealNum value. The parameters are the digits before the decimal point (integer part) and after it (fraction part). Example with the number 142.857:

>>> fromDigits [1, 4, 2] [8, 5, 7]
RealNum 142857 -3