当前位置:网站首页>#yyds干货盘点#【愚公系列】2022年08月 Go教学课程 008-数据类型之整型
#yyds干货盘点#【愚公系列】2022年08月 Go教学课程 008-数据类型之整型
2022-08-11 00:33:00 【51CTO】
一、数据类型概要
go语言中有四种数据类型:基础类型,复合类型,引用类型,接口类型。
| 类型 | 名称 | 长度 | 零值 | 说明 |
|---|---|---|---|---|
| bool | 布尔类型 | 1 | false | 其值不为真即为假,不可以用数字代表true或false |
| byte | 字节型 | 1 | 0 | uint8别名 |
| rune | 字符类型 | 4 | 0 | 专用于存储unicode编码,等价于uint32 |
| int, uint | 整型 | 4或8 | 0 | 有符号32位或无符号64位 |
| int8 | 整型 | 1 | 0 | -128~ 127, |
| uint8 | 整型 | 1 | 0 | 0~ 255 |
| int16 | 整型 | 2 | 0 | -32768 ~ 32767, |
| uint16 | 整型 | 2 | 0 | 0 ~ 65535 |
| int32 | 整型 | 4 | 0 | -2147483648到2147483647 |
| uint32 | 整型 | 4 | 0 | 0到4294967295(42亿) |
| int64 | 整型 | 8 | 0 | -9223372036854775808到9223372036854775807 |
| uint64 | 整型 | 8 | 0 | 0到18446744073709551615 ( 1844京) |
| float32 | 浮点型 | 4 | 0.0 | 小数位精确到7位 |
| float64 | 浮点型 | 8 | 0.0 | 小数位精确到15位 |
| complex64 | 复数类型 | 8 | ||
| complex128 | 复数类型 | 16 | 64位实数和虚数 | |
| uintptr | 整型 | 4或8 | 足以存储指针的uint32或uint64整数 | |
| strina | 字符串 | "” | utf-8字符串 |
二、整型
整型分为以下两个大类: 有符号整型、无符号整型。
- 有符号整型(int):正整数、负整数、0;按长度分为:int8、int16、int32、int64
- 无符号整型(uint):正整数、0;按长度分为:uint8、uint16、uint32、uint64
整型的范围:
- 有符号整型
- 32位系统:int是4个字节,范围:-2147483648到2147483647
- 64位系统:int是8个字节,范围:-9223372036854775808到9223372036854775807
- 无符号整型
- 在32位系统中:是4个字节,0到4294967295
- 在64位系统中:是8个字节,0到18446744073709551615
字节
- 位(bit):最小存储单位,计算机中存储的就是二进制0,1,位就是用来存储二进制。
- 字节(Byte):基本存储单位,用大写的B来表示,1字节=8bit, 1KB=1024B, 1MB=1024KB,1G=1024MB

边栏推荐
- 详谈二叉搜索树
- [GXYCTF2019]BabySQli
- 力扣------值相等的最小索引
- 微信小程序强制更新版本
- BEVDepth: Acquisition of Reliable Depth for Multi-view 3D Object Detection 论文笔记
- 【pypdf2】合并PDF、旋转、缩放、裁剪、加密解密、添加水印
- 力扣------用栈操作构建数组
- 报错:Client does not support authentication protocol requested by server; consider upgrading MySQL cli
- ② 关系数据库标准语言SQL 数据定义(创建、修改基本表)、数据更新(增删改)
- 【openpyxl】过滤和排序
猜你喜欢
随机推荐
力扣------使用最小花费爬楼梯
IEEE的论文哪里可以下载?
EN 12467纤维水泥平板产品—CE认证
2. Dependency management and automatic configuration
C#使用计时器
YOLOv5的Tricks | 【Trick13】YOLOv5的detect.py脚本的解析与简化
学习Apache ShardingSphere解析器源码(一)
两个链表的第一个公共节点——LeetCode
How to easily obtain the citation format of references?
electron -autoUpdater 更新
Only lazy and hungry. You still don't understand the singleton pattern!
How to do patent mining, the key is to find patent points, in fact, it is not too difficult
给肯德基打工的调料商,年赚两亿
如何做专利挖掘,关键是寻找专利点,其实并不太难
LeetCode_优先级队列_692.前K个高频单词
nodejs项目连接mysql数据库
李彦宏拆墙交朋友,大厂“塑料友情”能否帮百度啃下硬骨头?
Call activity of Activiti7 sub-process
池化技术有多牛?来,告诉你阿里的Druid为啥如此牛逼!
二维数组实战项目--------《扫雷游戏》


![[Excel knowledge and skills] Convert numeric format numbers to text format](/img/fb/79d6928456f090d47f0fe7a5074979.png)






