Answer the question
In order to leave comments, you need to log in
A typo in a book?
I read in the book "The Go Programming Language":
right shift of signed numbers fills the freed bits with copies of the sign bit.
right shifts of signed numbers fill the vacated bits with copies of the sign bit
Answer the question
In order to leave comments, you need to log in
You are misled by %b - for negative numbers, not the "real" binary representation is displayed (instead of 11111111 -1 is displayed).
https://stackoverflow.com/questions/49573389/forma...
https://stackoverflow.com/questions/37582550/golan...
Of course -1 is 11111111 for int8, but to get this output for %b, must be explicitly converted to uint8.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question