Advertisement
wzul

Bitwise and, Bitwise not

Aug 6th, 2020
1,264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.35 KB | None | 0 0
  1. <?php
  2.  
  3. $a = 2; // represent: 0000010
  4. $b = 1; // represent: 0000001 <-- kosong didepan ialah indikator positif
  5.  
  6. // bitwise and
  7. echo $a & $b; // output: 0 sebab kedua-duanya tidak ada nilai 1 pada tempat yang sama
  8. // 10 (binary)
  9. // 01 (binary)
  10. // --
  11. // 00 < equivalent to 0
  12.  
  13. // bitwise not
  14. echo ~$a; // output: -3 sebab 00010 inverse ialah 11101
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement