[Haskell-cafe] Best bit LIST data structure
Joachim Breitner
mail at joachim-breitner.de
Sun Oct 9 15:54:14 CEST 2011
Hi,
Am Freitag, den 07.10.2011, 10:52 -0400 schrieb Ryan Newton:
> What about just using the Data.Bits instance of Integer? Well,
> presently, the setBit instance for very large integers creates a whole
> new integer, shifts, and xors:
>
> http://haskell.org/ghc/docs/latest/html/libraries/base/src/Data-Bits.html#setBit
> (I don't know if it's possible to do better. From quick googling GMP
> seems to use an array of "limbs" rather than a chunked list, so maybe
> there's no way to treat large Integers as a list and update only the
> front...)
interesting idea. Should this be considered a bug in ghc? (Not that it
cannot represent the result, but that it crashes even out of ghci):
$ ghci
GHCi, version 7.0.4: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> :m + Data.Bits
Prelude Data.Bits> setBit 0 (2^63-1::Int)
gmp: overflow in mpz type
Abgebrochen
Greetings,
Joachim
--
Joachim "nomeata" Breitner
mail at joachim-breitner.de | nomeata at debian.org | GPG: 0x4743206C
xmpp: nomeata at joachim-breitner.de | http://www.joachim-breitner.de/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20111009/b0f92061/attachment.pgp>
More information about the Haskell-Cafe
mailing list