What does b: = a << 1 mean?

a := 42
	fmt.Printf("%d\t%b\t%#x\n", a, a, a)
	b := a << 1
	fmt.Printf("%d\t%b\t%#x\n", b, b, b)

It means left shifting which equal to multiplication 2 and for right shift division by 2…!
suppose 4 >> 1 is 2, and 4 << 1 is 8. Shifting left by one is the same as multiplication by 2, and shifting right by one is the same as dividing by two, in your case by assuming 8 bits
00101010 << 1 remove from left and insert from right res = 01010100

2 Likes