Closed comunidadio closed 10 months ago
The convention in Go, as in most programming languages, is that the least significant bits appear at the end.
E.g., if you set the bit at index 0, a 1 will appear at the last position:
package main
import (
"fmt"
)
func main() {
n := int64(1)
fmt.Printf("%064b", n)
}
Prints:
0000000000000000000000000000000000000000000000000000000000000001
If you want to reverse a string, it is relatively easy to do so in Go:
func Reverse(s string) string {
r := []rune(s)
for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
r[i], r[j] = r[j], r[i]
}
return string(r)
}
Outputs:
0000000000000000000000000000000000000100000000000000000000000000.0000000000000000000000000000000000000000000000000000010000000010.
Expected:
0100000000010000000000000000000000000000000000000000000000000000.0000000000000000000000000010000000000000000000000000000000000000.