Fun with Binary Numbers
| From: | David Buerer | Date: | Wed, 28 Aug 2002 14:11:51 +0000 |
| Subject: | Fun with Binary Numbers | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-114372@lists.php.net to get a copy of this message | ||
Here's a question,
Say I have a binary number like this
1101 0100 0110 0110
And I want to pull out of the binary number the third quartet (is that the
right word)
I want to know how to apply the mask
0000 1111 0000 0000
to the number above so that the result would be
0100
Likewise, given
the number: 1101 0100 0110 0110
and the mask 0000 0000 1111 0000
the result 0110
I suppose this is the same algorithm used to separate the host from the node
address given an IP address and a subnet mask. I just need to know what the
algorithm is.
Thanks
David