其实我一直理解是32位的。因为别的语言是这样,惯性思维了。 直接看一下官方文档:
int is a signed integer type that is at least 32 bits in size. It is a distinct type, however, and not an alias for, say, int32.
uint和int情况差不多。翻译一下,就是说这个整形最少占32位,int和int32是两码事。 再看一下 davecheney 大神的回复(大神半夜回复 GitHub 真是敬业啊):
uint is a variable sized type, on your 64 bit computer uint is 64 bits wide.
我的理解uint类型长度取决于 CPU,如果是32位CPU就是4个字节,如果是64位就是8个字节。我的电脑是64位的,而 playground 是32位的,问题就出在这里。 More