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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.