当前位置:网站首页>#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

边栏推荐
- "NIO Cup" 2022 Nioke Summer Multi-School Training Camp 2 DGHJKL Problem Solution
- 只会懒汉式和饿汉式 你还不懂单例模式!
- 【经典排序】快速排序
- IEEE的论文哪里可以下载?
- Volatile和CAS
- What is the ASIO4ALL
- Lens filter---about day and night dual-pass filter
- 【openpyxl】过滤和排序
- Analysis of LENS CRA and SENSOR CRA Matching Problems
- PMP每日一练 | 考试不迷路-8.10(包含敏捷+多选)
猜你喜欢
随机推荐
Mysql数据库安装配置详细教程
CF1427F-Boring Card Game【贪心】
13. Content Negotiation
[Data Visualization] Chart Design Principles
CF1286E-Fedya the Potter Strikes Back【KMP,RMQ】
HW-蓝队工作流程(1)
16. File upload
如何便捷获取参考文献的引用格式?
Only lazy and hungry. You still don't understand the singleton pattern!
Kunpeng compilation and debugging and basic knowledge of native development tools
BEVDepth: Acquisition of Reliable Depth for Multi-view 3D Object Detection 论文笔记
Why do programming languages have the concept of variable types?
Jvm. Profiling tools (jconsole, jvisualvm, arthas, jprofiler, mat)
YOLOv5的Tricks | 【Trick13】YOLOv5的detect.py脚本的解析与简化
关于科研学习中的几个问题:如何看论文?如何评价工作?如何找idea?
[Excel knowledge and skills] Convert "false" date to "true" date format
构建资源的弹性伸缩
二维数组实战项目--------《扫雷游戏》
ArcGIS Pro 创建tpk
异常和异常处理机制









