terryds Posted October 20, 2013 Share Posted October 20, 2013 Can someone explain me about bitwise operators for error reporting ? I've slightly understood about bitwise operators for numbers (http://www.litfuel.net/tutorials/bitwise.htm) But, What i don't understand is how to use it for error reporting? What will the symbol ^ , ~ , &, | mean ? Link to comment Share on other sites More sharing options...
davej Posted October 20, 2013 Share Posted October 20, 2013 (edited) $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 October 20, 2013 by davej Link to comment Share on other sites More sharing options...
birbal Posted October 21, 2013 Share Posted October 21, 2013 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now