fast-digits: Integer-to-digits conversion.

[ data, gpl, library ] [ Propose Tags ] [ Report a vulnerability ]

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.


[Skip to Readme]

library fast-digits

library fast-digits:fast-digits-internal

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.2.0.0, 0.2.1.0, 0.3.0.0, 0.3.1.0, 0.3.2.0
Change log changelog.md
Dependencies base (>=4.15 && <5), fast-digits, ghc-bignum (<1.4) [details]
Tested with ghc ==9.0.2, ghc ==9.2.8, ghc ==9.4.5, ghc ==9.6.2
License GPL-3.0-only
Author Andrew Lelechenko
Maintainer andrew.lelechenko@gmail.com
Category Data
Home page https://github.com/Bodigrim/fast-digits
Source repo head: git clone git://github.com/Bodigrim/fast-digits.git
Uploaded by Bodigrim at 2023-07-29T20:06:59Z
Distributions LTSHaskell:0.3.2.0, NixOS:0.3.2.0, Stackage:0.3.2.0
Reverse Dependencies 2 direct, 0 indirect [details]
Downloads 3535 total (40 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2023-07-29 [all 1 reports]

Readme for fast-digits-0.3.2.0

[back to package description]

fast-digits Hackage Stackage LTS Stackage Nightly

The fastest Haskell library to split integers into digits. It is both asymptotically (O(n1.4) vs. O(n2)) and practically (2x-40x for typical inputs) faster than Data.Digits.

Here are benchmarks for GHC 8.10:

> cabal bench -w ghc-8.10.4
All
  short
    2
      FastDigits:  OK (3.11s)
        12.3 ms ± 701 μs
      Data.Digits: OK (1.41s)
        22.2 ms ± 1.8 ms, 1.81x
    10
      FastDigits:  OK (2.11s)
        4.16 ms ± 369 μs
      Data.Digits: OK (3.74s)
        7.40 ms ± 235 μs, 1.78x
    100000
      FastDigits:  OK (4.89s)
        1.20 ms ±  69 μs
      Data.Digits: OK (3.96s)
        1.95 ms ±  78 μs, 1.63x
    1000000000
      FastDigits:  OK (4.02s)
        985  μs ±  62 μs
      Data.Digits: OK (3.15s)
        1.54 ms ±  70 μs, 1.56x
  medium
    2
      FastDigits:  OK (3.02s)
        1.49 ms ±  66 μs
      Data.Digits: OK (1.42s)
        5.62 ms ± 542 μs, 3.77x
    10
      FastDigits:  OK (2.35s)
        571  μs ±  42 μs
      Data.Digits: OK (1.77s)
        1.76 ms ± 152 μs, 3.07x
    100000
      FastDigits:  OK (3.87s)
        238  μs ±  19 μs
      Data.Digits: OK (3.44s)
        419  μs ±  23 μs, 1.76x
    1000000000
      FastDigits:  OK (3.05s)
        186  μs ±  13 μs
      Data.Digits: OK (4.42s)
        268  μs ±  11 μs, 1.44x
  long
    2
      FastDigits:  OK (3.75s)
        3.60 ms ± 215 μs
      Data.Digits: OK (1.89s)
        125  ms ± 9.6 ms, 34.88x
    10
      FastDigits:  OK (2.30s)
        2.24 ms ± 125 μs
      Data.Digits: OK (2.47s)
        39.0 ms ± 2.0 ms, 17.40x
    100000
      FastDigits:  OK (1.93s)
        1.88 ms ± 139 μs
      Data.Digits: OK (4.52s)
        8.82 ms ± 533 μs, 4.70x
    1000000000
      FastDigits:  OK (1.77s)
        1.71 ms ± 149 μs
      Data.Digits: OK (1.35s)
        5.30 ms ± 482 μs, 3.10x