fast-digits-0.2.1.0: The fast library for integer-to-digits conversion.

Copyright(c) Andrew Lelechenko, 2015-2016
LicenseGPL-3
Maintainerandrew.lelechenko@gmail.com
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Data.FastDigits

Description

Convert an integer to digits and back. Usually this library is twice as fast as Data.Digits. For small bases and long numbers it may be up to 40 times faster.

Synopsis

Documentation

digits Source #

Arguments

:: Int

The base to use

-> Integer

The number to convert

-> [Int]

Digits in reverse order

Return digits of a non-negative number in reverse order. Throw an error if number is negative or base is below 2.

digits 10 123 = [3, 2, 1]
digits 10 0   = []

undigits Source #

Arguments

:: (Integral a, Integral b) 
=> a

The base to use

-> [b]

The list of digits to convert

-> Integer 

Return an integer, built from given digits in reverse order. Condition 0 ≤ digit < base is not checked.

digitsUnsigned Source #

Arguments

:: Word

Precondition that base is ≥2 is not checked

-> Natural 
-> [Word] 

Return digits of a non-negative number in reverse order.