Why ^0(int variable) = -1 in go

func main() {
var a int64 = ^0
fmt.Printf("%b\n", a)

Why the console print “-1”?

Because that is how negative numbers are represented internally. -1 is represented by setting all bits 1.

Thanks, I get it.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.