in reply to behavior of bitwise shift

perl seems to use a 32bit integer on your machine (i have a 64bit SPARC and perl uses 32bit too, is this standat or would i just have to conifgure my gcc in a proper way?). now perl bitshift is not shifting to nirvana but looping, so the binary one is shifting to the left (or right, depends on how you look at binarys) reaches the end and then starts from the beginning (lowest value bit).

Replies are listed 'Best First'.
Re^2: behavior of bitwise shift
by pg (Canon) on Oct 25, 2004 at 17:12 UTC

    That's right, the underlying c is 32 bit, and Perl simply uses c <<. It is said in perlop that:

    "The result of overflowing the range of the integers is undefined because it is undefined also in C. In other words, using 32-bit integers, 1 << 32 is undefined. Shifting by a negative number of bits is also undefined."