Here simple working code to left shift first bit of a byte
package main
import (
"fmt"
)
type Byte byte
func SL(b Byte) Byte {
if b&0x80 == 0x80 {
b <<= 1
b ^= 0x01
} else {
b <<= 1
}
return b
}
func main() {
var b Byte
b = 0xD3
fmt.Printf("old byte %#08b
", b) // 11010011
c := SL(b)
fmt.Printf("new byte %#08b", c) // 10100111
}
What should I do to shift array of bytes, like
type Byte [2]byte
?
Thanks for advance!