Usually displaying something like that in decimal would be nonsensical.use strict; use warnings; my $HIGH_BITS = 0xFFFFFFFF << 28; printf "%X\n", $HIGH_BITS; # prints: FFFFFFFF0000000 # each hex digit is 4 bits, 7 zeroes x4 = 28 bits left shifted
If you have an "all ones" in a 32 bit register, and you shift the contents 28 bits to the left, the high nibble will be "F". This will result in a negative value as viewed as a 2's complement number.
Update: jwkrahn came up with the ball on this one:
The trick is how to get Perl to display this value as signed integer.
On Windows the quoting is a bit different, But this works on my Windows machine.
A simple: print $HIGH_BITS on my machine yields: 1152921504338411520 which of course is not right. This looks like the unsigned decimal value.>perl -le "my $HIGH_BITS = unpack "l", pack "l", 0xFFFFFFFF << 28; pri +nt $HIGH_BITS; " -268435456
In reply to Re: Difference between Perl and Java for << operator?
by Marshall
in thread Difference between Perl and Java for << operator?
by davidfilmer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |