kenchucky Posted March 4, 2008 Share Posted March 4, 2008 I know that I can use & to see whether a bit is off or on, | to turn a bit on, ^ to toggle a bit, << to left shift and >> to right shift, but I can't figure out how to turn a bit off (bitwise NOT). What is the command to do this in MySQL? P.S. Also, what is it in PHP? And what is the bitwise XOR command in PHP? I tried ^ but is the command for power to (10^3==1000) P.P.S How do I declare an unsigned 8 bit integer in PHP? (int) works for signed 32 bit, but I can't get (uint to work. Link to comment https://forums.phpfreaks.com/topic/94358-bitwise-not/ Share on other sites More sharing options...
fenway Posted March 4, 2008 Share Posted March 4, 2008 See this refman page. Link to comment https://forums.phpfreaks.com/topic/94358-bitwise-not/#findComment-483277 Share on other sites More sharing options...
kenchucky Posted March 4, 2008 Author Share Posted March 4, 2008 That is where I found the ones that I listed. I could not find the bitwise NOT operation on it. Like 96 (NOT) 32 would become 64, and 64 (NOT) 32 would stay as 64. The opposite of bitwise OR (64 | 32 becomes 96, and 96 | 32 stays 96). Link to comment https://forums.phpfreaks.com/topic/94358-bitwise-not/#findComment-483319 Share on other sites More sharing options...
Barand Posted March 4, 2008 Share Posted March 4, 2008 P.S. Also, what is it in PHP? And what is the bitwise XOR command in PHP? I tried ^ but is the command for power to (10^3==1000) P.P.S How do I declare an unsigned 8 bit integer in PHP? (int) works for signed 32 bit, but I can't get (uint to work. First, let's kill your fallacy that ^ is the power operator in PHP <?php echo 10 ^ 3; // 9 echo pow(10, 3); // 1000 ?> Now, XOR. You didn't try very hard, did you? <?php $a = 0xAA; echo decbin($a); // 10101010 (8 bits) $b = 0xFF; echo decbin($b); // 11111111 $c = $a ^ $b; // xor echo decbin($c); // 01010101 $d = $c ^ $b ; echo decbin($d); // 10101010 ?> Link to comment https://forums.phpfreaks.com/topic/94358-bitwise-not/#findComment-483352 Share on other sites More sharing options...
Barand Posted March 4, 2008 Share Posted March 4, 2008 That is where I found the ones that I listed. I could not find the bitwise NOT operation on it. Like 96 (NOT) 32 would become 64, and 64 (NOT) 32 would stay as 64. The opposite of bitwise OR (64 | 32 becomes 96, and 96 | 32 stays 96). SELECT 96 & ~32 --> 64 Link to comment https://forums.phpfreaks.com/topic/94358-bitwise-not/#findComment-483376 Share on other sites More sharing options...
kenchucky Posted March 5, 2008 Author Share Posted March 5, 2008 Thank you guys. Link to comment https://forums.phpfreaks.com/topic/94358-bitwise-not/#findComment-483716 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.