Jump to content

Bitwise operator for error reporting


terryds

Recommended Posts

$a & $b And 	Bits that are set in both $a and $b are set.$a | $b Or 	Bits that are set in either $a or $b are set.$a ^ $b Xor 	Bits that are set in $a or $b but not both are set.~ $a 	Not 	Bits that are set in $a are not set, and vice versa.$a << $b Shift left 	Shift the bits of $a $b steps to the left (each step means "multiply by two")$a >> $b Shift right 	Shift the bits of $a $b steps to the right (each step means "divide by two") 

In other words;

 

$mask = 1;// this is actually something like 000000001 only bit zero is a one

$mask2 = ~$mask; // this flips the bits so it is now something like 1111111111110

$out1 = $in | $mask; // now bit zero is forced to be a one

$out2 = $in & $mask2; // now bit zero is forced to be a zero

Edited by davej
Link to comment
Share on other sites

error reporting constant is also a number. so applying bitwise operator on them is same as applying on numbers.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...