Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualCagnazzo

Posted 25 November 2012 - 05:00 PM

I think you might be mixing 16 up with 15.

255 is, in binary, 11111111.
16 is, in binary, 0001000.

The reason you can take any number up to 255 and logical and it with 255 and get that number back, is because 255 is basically ones everywhere - so if the number you're &ing has a zero in a slot, the result is zero in that slot - if it has a one, the result is one. 1&x is simply equal to x.

0&x is always equal to zero though. So if you're &ing with 16, the the sixteenth place is always going to be the only place that could possibly be nonzero. You'll end up with either 16 or 0.

Does that make sense? I suspect you meant to be using 15, which would be 00001111.

#2Cagnazzo

Posted 25 November 2012 - 05:00 PM

I think you might be mixing 16 up with 15.

255 is, in binary, 11111111.
16 is, in binary, 0001000.

The reason you can take any number up to 255 and logical and it with 255 and get that number back, is because 255 is basically ones everywhere - so if the number you're &ing has a zero in a slot, the result is zero in that slot - if it has a one, the result is one. 1&x is simply equal to x.

0&x is always equal to zero though. So if you're &ing with 16, the the sixteenth place is always going to be the only place that could possibly be preserved.

Does that make sense? I suspect you meant to be using 15, which would be 00001111.

#1Cagnazzo

Posted 25 November 2012 - 04:58 PM

I think you might be mixing 16 up with 15.

255 is, in binary, 11111111.
16 is, in binary, 00010000.

The reason you can take any number up to 255 and logical and it with 255 and get that number back, is because 255 is basically ones everywhere - so if the number you're &ing has a zero in a slot, the result is zero in that slot - if it has a one, the result is one. 1&x is simply equal to x.

0&x is always equal to zero though. So if you're &ing with 16, the the sixteenth place is always going to be the only place that could possibly be preserved.

Does that make sense? I suspect you meant to be using 15, which would be 00001111.

PARTNERS