Number of digits in a number in decimal and hexadecimal representation.

Latest on Hackage:

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow to host generated Haddocks.

BSD3 licensed by Peter Trško
Maintained by

Number Length

Hackage Hackage Dependencies [Haskell Programming Language][] [BSD3 License][tl;dr Legal: BSD3]

Build Coverage Status


Number length in decimal and hexadecimal representation.

There are situations when it is necessary to know the length of a number in decimal or hexadecimal form. In example when allocating buffer while serializing a number in to binary or human readable format.

λ> numberLength (123 :: Int)

λ> numberLengthHex (123 :: Int)  -- 123 = 7b in hex

Building Options

  • -fpedantic (disabled by default)

    Pass additional warning flags to GHC.


The BSD 3-Clause License, see [LICENSE][] file for details.


Contributions, pull requests and bug reports are welcome! Please don't be afraid to contact author using GitHub or by e-mail. "Package number-length on Hackage" []: "The Haskell Programming Language" [LICENSE]: "License of number-length package." [tl;dr Legal: BSD3]: "BSD 3-Clause License (Revised)"


ChangeLog / ReleaseNotes


  • Depend on quickcheck-instances to provide instance Arbitrary Natural for unit tests. (minor change)


  • Instances for Integer and Natural.
  • Build on GHC 8.2.2 and Stackage LTS 10.*.


  • Removed dead code. (minor change)
  • Better and expanded test suite, which now includes tests for methods of SignedNumberLength. (minor change)
  • Depending on tagged package only for GHC <7.8. This is due to the fact, that Data.Proxy module was introduce in base ==4.7, which was bundled with GHC 7.8. (minor change)
  • Small examples included in description. (minor change)
  • Uploaded to Hackage:

Version "HackageDB (or just Hackage) is a collection of releases of Haskell packages."

Depends on 1 package:
Used by 1 package:
comments powered byDisqus