当前位置:网站首页>#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
边栏推荐
- 单片机人机交互--矩阵按键
- Where can I download IEEE papers?
- [Excel知识技能] 将“假“日期转为“真“日期格式
- 2022.8.10-----leetcode.640
- 91.(cesium之家)cesium火箭发射模拟
- 5. Lombok
- YOLOv5的Tricks | 【Trick11】在线模型训练可视化工具wandb(Weights & Biases)
- UOJ#749-[UNR #6]稳健型选手【贪心,分治,主席树】
- LENS CRA和SENSOR CRA匹配问题解析
- EPro-PnP: Generalized End-to-End Probabilistic Perspective-n-Points for Monocular Object Pose Est...
猜你喜欢
How to do patent mining, the key is to find patent points, in fact, it is not too difficult
EN 12467纤维水泥平板产品—CE认证
【21天学习挑战赛】折半插入排序
YOLOv5的Tricks | 【Trick13】YOLOv5的detect.py脚本的解析与简化
【爬虫】scrapy创建运行爬虫、解析页面(嵌套url)、自定义中间件(设置UserAgent和代理IP)、自定义管道(保存到mysql)
关于编程本质那些事
异常和异常处理机制
详解JDBC的实现与优化(万字详解)
深度解析volatile关键字(保证够全面)
【考虫 六级英语】语法课笔记
随机推荐
I caught a 10-year-old Ali test developer, and after talking about it, I made a lot of money...
Only lazy and hungry. You still don't understand the singleton pattern!
Jvm.分析工具(jconsole,jvisualvm,arthas,jprofiler,mat)
input输入框超出部分用省略号表示以及判断内容是否有超出(PC端)
工程师如何对待开源
sqlmap combined with dnslog fast injection
Distributed. Performance optimization
12. Handling JSON
盘点美军的无人机家底
YOLOv5的Tricks | 【Trick10】从PyTorch Hub加载YOLOv5
【pypdf2】合并PDF、旋转、缩放、裁剪、加密解密、添加水印
线上突然查询变慢怎么核查
5. Lombok
[数据可视化] 图表设计原则
Shell 文本三剑客 Sed
HW-蓝队工作流程(1)
What is the ASIO4ALL
In 22 years, the salary of programmers nationwide in January was released, only to know that there are so many with annual salary of more than 400,000?
图像识别和语义分割的区别
SAP ABAP JSON 格式数据处理