mitd has asked for the wisdom of the Perl Monks concerning the following question:
Why does this:
my ($perms, $type) = @ARGV; print "Other Test: ", ($perms & $type ) ,"\n"; print "Group Test: ", ($perms & ($type << 3 )),"\n"; print "Owner Test: ", ($perms & ($type << 4)),"\n"; # with command line params: 63,1;
Produce this:
Other Test: 0
Group Test: 8
Owner Test: 16
And this:
my ($perms, $type) = @ARGV; print "Other Test: ", ($perms & ($type << 0) ,"\n"; print "Group Test: ", ($perms & ($type << 3 )),"\n"; print "Owner Test: ", ($perms & ($type << 4)),"\n"; # with command line params: 63,1;
Produce this:
Other Test: 1
Group Test: 8
Owner Test: 16
Well snap my deerskin thong! I just figured her out,
but shoot I think I'll post her anyways.
mitd-Made in the Dark
I've always been astonished by the absurd turns
rivers have to make to flow under every bridge.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Bit Shifting ?
by MarkM (Curate) on Apr 06, 2003 at 03:21 UTC |