The maximum value for an int type in Go

前端 未结 10 930
无人共我
无人共我 2021-01-29 19:09

How does one specify the maximum value representable for an unsigned integer type?

I would like to know how to initialize min in the loop below

10条回答
  •  别那么骄傲
    2021-01-29 19:30

    https://golang.org/ref/spec#Numeric_types for physical type limits.

    The max values are defined in the math package so in your case: math.MaxUint32

    Watch out as there is no overflow - incrementing past max causes wraparound.

提交回复
热议问题