golang基础数据类型-整型

Go语言提供有符号和无符号整数类型,如int、uint,其大小与平台相关。别名类型如uintptr用于存储指针。零值通常为有符号的int,而无符号整数常用于位运算和特殊运算场景。尽管有无符号选择,但Go编程中更常用有符号int,如len()函数返回类型。无符号数溢出不会抛出错误,math包定义了边界值。
摘要由CSDN通过智能技术生成

go同时提供了有符号和无符号的整数类型

有符号

// int8 is the set of all signed 8-bit integers.
// Range: -128 through 127.
type int8 int8

// int16 is the set of all signed 16-bit integers.
// Range: -32768 through 32767.
type int16 int16

// int32 is the set of all signed 32-bit integers.
// Range: -2147483648 through 2147483647.
type int32 int32

// int64 is the set of all signed 64-bit integers.
// Range: -9223372036854775808 through 9223372036854775807.
type int64 int64

无符号

// uint8 is the set of all unsigned 8-bit integers.
// Range: 0 through 255.
type uint8 uint8

// uint16 is the set of all unsigned 16-bit integers.
// Range: 0 through 65535.
type uint16 uint16

// uint32 is the set of all unsigned 32-bit integers.
// Range: 0 through 4294967295.
type uint32 uint32

// uint64 is the set of all unsigned 64-bit integers.
// Range: 0 through 18446744073709551615.
type uint64 uint64

和平台相关

无固定大小,和特定平台相关,32位平台就是32位,64位平台就是64位

// int is a signed integer type that is at least 32 bits in size. It is a
// distinct type
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值