常用位操作技巧(Golang)
1,判断奇偶 for i := 0; i < 100; i++ { if i % 2 == 0 { println(i) } if i & 0x1 == 0 { println(i) } } 2,交换两个数 func Swap(a, b *int) { if *a^*b != 0 { temp := *a *a = *b *b = temp } } func Swap(a, b *int) { if *a^*b != 0 { *a = *a + *b *b = *a - *b *a = *a -...阅读全文