GOLANG笔记1-基础数据类型
int 和 uint
uint类型长度取决于 CPU,如果是32位CPU就是4个字节,如果是64位就是8个字节。我的电脑是64位的,而 playground 是32位的
int是带符号的,表示范围是:-2147483648到2147483648,即-2^31到2^31次方。
uint则是不带符号的,表示范围是:2^32即0到4294967295。
uint可以使用十进制,二进制,十六进制。和long,ulong,float,double,decimal等预定义可以进行隐式转换。但是需要注意值是否在可转换的范围内,不然会出现异常。
The Uint keyword signifies an integral type that stores calues according to the size and ranges shown in the following table.
关键字表示一种整型类型,该类型根据下表显示的大小和范围存储值。
————————————————
golang数据类型:
布尔类型
true false
数字类型 整形 浮点型
整形:
无符号:uint 8、uint 16、uint 32、uint 64、长度(0~2次方-1)
有符号:int 8、int 16、int 32、int 64、长度:例如int 8(负的2^7~2^7-1)
有无符号:没有符号位的数字只能有0和正值,有符号位的数字可以有正零,负零和正数负数.
浮点型:float(32单精度) float(64双精度)
序号 | 类型和描述 |
---|---|
1 | float32 IEEE-754 32位浮点型数 |
2 | float64 IEEE-754 64位浮点型数 |
3 | complex64 32 位实数和虚数 |
4 | complex128 64 位实数和虚数 |
字符串类型
派生类型
派生类型:
- (a) 指针类型(Pointer)
- (b) 数组类型
- (c) 结构化类型(struct)
- (d) Channel 类型
- (e) 函数类型
- (f) 切片类型
- (g) 接口类型(interface)
- (h) Map 类型
虚数:https://www.ruanyifeng.com/blog/2012/09/imaginary_number.html
原文链接:https://blog.csdn.net/janny_flower/article/details/81082424
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
Comment
Powered By Valine
v1.5.1
v1.5.1