bitwise_complement.go 500 B

12345678910111213141516171819202122
  1. package main
  2. import "fmt"
  3. func main() {
  4. for i:=0; i <= 10; i ++ {
  5. fmt.Printf("the complement of %b is: %b\n", i, ^i)
  6. }
  7. }
  8. /* Output:
  9. the complement of 0 is: -1
  10. the complement of 1 is: -10
  11. the complement of 10 is: -11
  12. the complement of 11 is: -100
  13. the complement of 100 is: -101
  14. the complement of 101 is: -110
  15. the complement of 110 is: -111
  16. the complement of 111 is: -1000
  17. the complement of 1000 is: -1001
  18. the complement of 1001 is: -1010
  19. the complement of 1010 is: -1011
  20. */