Go规范中“无符号”,“有符号”和“虚数”的含义是什么?

在Go中,有一个部分用于数字类型,但我不太清楚某些定义。在这种情况下,“无符号”,“所有有符号的集合”,“虚构部分”是什么意思?


uint8       the set of all unsigned  8-bit integers (0 to 255)

uint16      the set of all unsigned 16-bit integers (0 to 65535)

uint32      the set of all unsigned 32-bit integers (0 to 4294967295)

uint64      the set of all unsigned 64-bit integers (0 to 18446744073709551615)


int8        the set of all signed  8-bit integers (-128 to 127)

int16       the set of all signed 16-bit integers (-32768 to 32767)

int32       the set of all signed 32-bit integers (-2147483648 to 2147483647)

int64       the set of all signed 64-bit integers (-9223372036854775808 to 9223372036854775807)


float32     the set of all IEEE-754 32-bit floating-point numbers

float64     the set of all IEEE-754 64-bit floating-point numbers


complex64   the set of all complex numbers with float32 real and imaginary parts

complex128  the set of all complex numbers with float64 real and imaginary parts


byte        alias for uint8

rune        alias for int32

参考资料: https://golang.org/ref/spec#Numeric_types



慕容3067478
浏览 115回答 1
1回答

墨色风雨

var x complex128 = complex(1, 2) // 1+2i复数的最大值:complex128(1.7976931348623157e+308 + 1.7976931348623157e+308 i)如果你熟悉复数,那么你可以理解它。否则这里 = 或iroot of (-1)i^2 = -1无符号表示仅正数和 0。uint64 系列0 to 18,446,744,073,709,551,615uint32 范围0 to 4,294,967,295和平均值 从负到正的总数范围set of signed
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Go