I'm trying to compute the Hamming distance between two byte's, such that
HammingDist(byte(255), byte(0)) == 8
I need the bits in each byte, but I can't find any function in any of the built-in packages for doing so. So, given byte(1)
how do I get the bit representation 00000001?
You can simply do:
fmt.Printf("%08b", YourNumber)
You can also use %016b
or %032b
or any other.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With