[Numpy-discussion] Purpose for bit-wise and'ing the initial mersenne twister key?
Michael S. Gilbert
Fri Feb 6 16:57:23 CST 2009
Ok, so isn't this a slight waste of memory then (a doubling on 64-bit platforms)? Of course the tradeoff is whether you want to maintain two codebases for 32- and 64-bit or just one. The advantages of a single codebase probably outweight an increase in memory usage since we're only talking about the difference between 2kB and 4kB, which is fairly insignificant.
On Fri, 6 Feb 2009 15:25:35 -0600
Robert Kern <email@example.com> wrote:
> On Fri, Feb 6, 2009 at 15:24, Michael S. Gilbert
> <firstname.lastname@example.org> wrote:
> > In numpy/random/mtrand/randomkit.c on line 159, the initial mersenne twister key (populated from /dev/urandom) gets bit-wise and'ed with 0xffffffff. I'm just curious as why this is done. A bit-wise and with all ones should just give you your original quantity back, right? I don't think there is a problem since the operation doesn't really do anything, and the same thing exists in the mersenne twister reference code, but I am curious as to why it is even there in the first place. Thanks for any thoughts.
> On most 64-bit machines, unsigned longs are 64 bits, so 0xffffffffUL
> is only 32 bits of 1s.
> Robert Kern
> "I have come to believe that the whole world is an enigma, a harmless
> enigma that is made terrible by our own mad attempt to interpret it as
> though it had an underlying truth."
> -- Umberto Eco
> Numpy-discussion mailing list
More information about the Numpy-discussion