# fast-digits: Integer-to-digits conversion.

[ data, gpl, library ] [ Propose Tags ]

Convert an integer to digits and back. This library is both asymptotically (O(n^1.4) vs. O(n^2)) and practically (2x-40x for typical inputs) faster than Data.Digits.

Versions [faq] 0.1.0.0, 0.2.0.0, 0.2.1.0, 0.3.0.0 changelog.md base (>=4.8 && <5), integer-gmp (>=1.0) [details] GPL-3.0-only Andrew Lelechenko andrew.lelechenko@gmail.com Data https://github.com/Bodigrim/fast-digits head: git clone git://github.com/Bodigrim/fast-digits.git by Bodigrim at 2020-02-03T19:46:43Z LTSHaskell:0.2.1.0, NixOS:0.3.0.0, Stackage:0.2.1.0 2522 total (14 in the last 30 days) (no votes yet) [estimated by Bayesian average] λ λ λ Docs available Last success reported on 2020-02-03

## Modules

[Index] [Quick Jump]

#### Maintainer's Corner

For package maintainers and hackage trustees

## Readme for fast-digits-0.3.0.0

[back to package description]

# fast-digits

The fastest Haskell library to split integers into digits. It is both asymptotically (O(n<sup>1.4</sup>) vs. O(n<sup>2</sup>)) and practically (2x-40x for typical inputs) faster than Data.Digits.

Here are some benchmarks:

> cabal bench
shortInt/FastDigits  base 2              mean 6.429 ms  ( +- 465.7 μs  )
shortInt/Data.Digits base 2              mean 50.08 ms  ( +- 1.848 ms  )

shortInt/FastDigits  base 10             mean 4.288 ms  ( +- 217.1 μs  )
shortInt/Data.Digits base 10             mean 15.62 ms  ( +- 540.1 μs  )

shortInt/FastDigits  base 10^5           mean 1.142 ms  ( +- 50.09 μs  )
shortInt/Data.Digits base 10^5           mean 3.962 ms  ( +- 269.1 μs  )

shortInt/FastDigits  base 10^9           mean 963.8 μs  ( +- 46.13 μs  )
shortInt/Data.Digits base 10^9           mean 3.052 ms  ( +- 238.5 μs  )

mediumInt/FastDigits  base 2             mean 1.213 ms  ( +- 185.0 μs  )
mediumInt/Data.Digits base 2             mean 12.41 ms  ( +- 3.417 ms  )

mediumInt/FastDigits  base 10            mean 689.3 μs  ( +- 32.43 μs  )
mediumInt/Data.Digits base 10            mean 3.271 ms  ( +- 137.3 μs  )

mediumInt/FastDigits  base 10^5          mean 220.1 μs  ( +- 11.30 μs  )
mediumInt/Data.Digits base 10^5          mean 711.1 μs  ( +- 67.31 μs  )

mediumInt/FastDigits  base 10^9          mean 156.0 μs  ( +- 9.115 μs  )
mediumInt/Data.Digits base 10^9          mean 407.9 μs  ( +- 19.58 μs  )

longInt/FastDigits  base 2               mean 3.515 ms  ( +- 189.7 μs  )
longInt/Data.Digits base 2               mean 183.2 ms  ( +- 4.564 ms  )

longInt/FastDigits  base 10              mean 2.164 ms  ( +- 134.7 μs  )
longInt/Data.Digits base 10              mean 55.45 ms  ( +- 946.7 μs  )

longInt/FastDigits  base 10^5            mean 1.467 ms  ( +- 60.49 μs  )
longInt/Data.Digits base 10^5            mean 11.09 ms  ( +- 347.0 μs  )

longInt/FastDigits  base 10^9            mean 1.242 ms  ( +- 52.92 μs  )
longInt/Data.Digits base 10^9            mean 6.181 ms  ( +- 226.1 μs  )