Advertisement
mhyusuf

Xor without xor

Oct 16th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.17 KB | None | 0 0
  1. <?php
  2. // find XOR
  3.  
  4. // Returns XOR of x and y
  5. function myXOR($x, $y)
  6. {
  7.    return ($x | $y) & (~$x | ~$y);
  8. }
  9.  
  10. echo myXOR(3, 4) . " sama dengan " . (3 ^ 4)
  11.  
  12. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement