Advertisement
cwchen

[Go] Bitwise operators

Sep 9th, 2017
473
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.26 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5. )
  6.  
  7. const EXEC = 1  // 0001
  8. const WRITE = 2 // 0010
  9. const READ = 4  // 0100
  10.  
  11. func main() {
  12.     // Read only
  13.     fmt.Println(READ)
  14.  
  15.     // Read and write
  16.     fmt.Println(READ ^ WRITE)
  17.  
  18.     // Read and Exec
  19.     fmt.Println(READ ^ EXEC)
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement