Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

bitwise left shift

package main

import "fmt"

func main() {
	x := 1
	for i := 0; i <= 8; i++ {
		y := x << i
		fmt.Printf("%3v %9b\n", y, y)
	}
	fmt.Println()

	a := 42
	fmt.Printf("%3v %9b", a, a)

}
  1         1
  2        10
  4       100
  8      1000
 16     10000
 32    100000
 64   1000000
128  10000000
256 100000000

 42    101010