number-length

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

https://github.com/trskop/number-length

Latest on Hackage:0.2.1.0

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 stackage.org to host generated Haddocks.

BSD-3-Clause licensed by Peter Trško
Maintained by [email protected]

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)
3
λ> numberLengthHex (123 :: Int)  -- 123 = 7b in hex
2