bitwise not



examples/bitwise-not/bitwise_not.go
package main

import "fmt"

func main() {
    fmt.Println("uint8")
    numbersUint8 := []uint8{1, 2, 5}
    for _, n := range numbersUint8 {
        fmt.Printf("%3v %9b\n", n, n)
        fmt.Printf("%3v %9b\n", ^n, ^n)

    }

    fmt.Println("\nint8")
    numbersInt8 := []int8{1, 2, 5}
    for _, n := range numbersInt8 {
        fmt.Printf("%3v %9b\n", n, n)
        fmt.Printf("%3v %9b\n", ^n, ^n)
    }

}

examples/bitwise-not/bitwise_not.out
uint8
  1         1
254  11111110
  2        10
253  11111101
  5       101
250  11111010

int8
  1         1
 -2       -10
  2        10
 -3       -11
  5       101
 -6      -110