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

Copyright(c) Andrew Lelechenko, 2015
LicenseGPL-3
Maintainerandrew.lelechenko@gmail.com
Stabilityexperimental
PortabilityPOSIX
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 30 times faster.

Synopsis

Documentation

digits Source

Arguments

:: Int

The base to use

-> Integer

The integer to convert

-> [Int] 

Return digits of a non-negative integer in reverse order. E. g.,

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

Throw an error if number is negative or base is below 2.

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.