From your other answers, I think I can help you further by showing the same numbers as above in binary form:
DB<5> printf "%04b", $mode ;
1000000111101101
DB<6> printf "%04b", 07777;
111111111111
DB<7>
So, 33261 is 1000000111101101 in binary representation, and 07777 is 111111111111 (or the equivalent 0000111111111111) in binary representation. If we now do manually a bitwise and (&) between these two numbers, we do this:
1000000111101101 &
0000111111111111
================
= 0000000111101101
We get a 1 in the result only at places where we have a 1 in both numbers above. This is in effect applying a mask to cancel out the four binary digits on the left in the original number. The same operation under the debugger:
DB<8> $c = $mode & 07777;
DB<9> printf "%04b", $c;
111101101
DB<10>
If I now print that same $c number in its octal representation:
DB<10> printf "%04o", $c;
0755
DB<11>
Is it clearer in your mind now?
|