Jump to content

Studying for my PHP Cert.


Michael Dick

Recommended Posts

bitwise operators are used in doing binary math. Just like doing normal base 10 math that you are used to, except for in base 2.

let's say you have this:

$a = 16;
echo $a << 2;

$a would echo 64. why? well lets look at those numbers in base 2:

00010000 // this is 16 in base 10
01000000 // this is 64 in base 10

$a << 2 shifts the bit over 2 'spaces'. all 8 of those 'spaces' is called a byte. each space is called a bit. now you might better understand this in terms of kilobytes, megabytes, gigabytes, etc.. well this is the base level of that.

here is a really good tutoral on binary mathematics:

[a href=\"http://www.litfuel.net/tutorials/bitwise.htm\" target=\"_blank\"]http://www.litfuel.net/tutorials/bitwise.htm[/a]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.