MyNixOS website logo
Description

Integer-to-digits conversion.

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.

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
Metadata

Version

0.3.2.0

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows