[Haskell] for large x, log (x::Integer) :: Double

Dylan Thurston dpt at lotus.bostoncoop.net
Tue Jul 13 05:01:32 EDT 2004

On Mon, Jul 12, 2004 at 04:29:22PM +0200, Ronny Wichers Schreur wrote:
> Edmund GRIMLEY EVANS asks (to the Haskell mailing list):
> >Does Haskell provide any means of determining the number of
> >binary digits in an Integer other than by repeated division?
> Dylan Thurston answers:
> >See the Data.Bits library:
> >
> >http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data.Bits.html
> This library will let you use a shift instead of a division,
> but won't give you a constant time size function for Integers.

You can easily get a logarithmic time size function from the shift.
But did you see Data.Bits.bitsize?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org//pipermail/haskell/attachments/20040713/1cb9898b/attachment.bin

More information about the Haskell mailing list