In the Go Tour, page 13, the following is presented:
MaxInt uint64 = 1<<64 - 1
It evaluates correctly as seen when the example gets run; I just can't seem to understand why.
unit64
is the biggest container for an int in Go as far as I understand. At the same time 1<<64
evaluates to an exception when used in an expression (such as in fmt.Printf(1<<64)
) - that is it's not 0 as in several programming languages. Still, when used on the right side of the assignment operator it evaluates fine.
What am I missing here?
Never mind, slide #15 seems to explain it: it's a constant and as such "does not have limited size" (not to 64 bits anyway). I feel it strange but it's OK for an explanation.