in reply to Need data struct that can hold 64 bits of info (was: bitboards in perl)

perlfunc on vec() : "BITS therefore specifies the number of bits that are reserved for each element in the bit vector. This must be a power of two from 1 to 32 (or 64, if your platform supports that). " I guess I could just use two 32 bit elements and make my own bitwise operators...

Replies are listed 'Best First'.
(crazyinsomniac) Re: Re: bitboards in perl
by crazyinsomniac (Prior) on Feb 24, 2002 at 16:10 UTC
Re: Re: bitboards in perl
by Zaxo (Archbishop) on Feb 24, 2002 at 20:09 UTC
    ...reserved for each element in the bit vector.

    You were wanting 64 bits, so each is one bit wide. This is 32-bit perl:

    $ perl -e 'vec( $foo, 63, 1) = 1; print unpack( "b64",$foo),$/' 0000000000000000000000000000000000000000000000000000000000000001
    or, if you prefer your high order bits printed on the left,
    $ perl -e 'vec( $foo, 63, 1) = 1; print scalar reverse(unpack "b64",$f +oo),$/' 1000000000000000000000000000000000000000000000000000000000000000
    The bitwise operators work on vec() strings

    After Compline,
    Zaxo