当前位置:网站首页>Go learning notes (3) basic types and statements (2)
Go learning notes (3) basic types and statements (2)
2022-07-06 07:53:00 【Raring_ Ringtail】
Take the book back , I cleaned it up yesterday go In words , Let's sort it out today go Boolean and numeric types in the basic types of .
Boolean (Booleans) type
bool
There's nothing to say about type , It's only worth two true
and false
, Its zero value is false
.
var flag bool // If there is no assignment, it will be set to zero false
var isBeautiful = true
value type
go Yes 12 Different numerical types , They fall into three categories : integer 、 floating-point 、 The plural .go The value type of is not like c In that language char
、short
、int
、long
、float
、double
This type of numeric value related to the number of bits in the operating system .
For integer types , It is used uniformly int
Represents and marks its digits after . The following table :
Type name | Value range |
---|---|
int8 | -128 to 127 |
int16 | –32768 to 32767 |
int32 | –2147483648 to 2147483647 |
int64 | –9223372036854775808 to 9223372036854775807 |
uint8 | 0 to 255 |
uint16 | 0 to 65536 |
uint32 | 0 to 4294967295 |
uint64 | 0 to 18446744073709551615 |
For floating point types , It USES float32
and float64
Express 32 Bit and 64 Bit floating point . The following table :
Type name | Maximum absolute value | Minimum non-zero absolute value |
---|---|---|
float32 | 3.40282346638528859811704183484516925440e+38 | 1.401298464324817070923729583289916131280e-45 |
float64 | 1.797693134862315708145274237317043567981e+308 | 4.940656458412465441765687928682213723651e-324 |
Several special integer types
byte
yes uint8
Alias , The two are completely equivalent .
int
stay 32 Bit system is int32
stay 64 Bit system is int64
, So when int
And int32
or int64
There will be compilation errors in the assignment comparison or mathematical calculation of variables of .go Language does not support implicit type conversion between variables , This is also what I like very much go A point of language ,go Many grammatical and semantic mistakes are directly prohibited , Although not so convenient , But it makes the code clearer .
uint
And int
Similar is just non negative .
The default value of the whole number is int
type .
rune
and uintptr
It is also two special integer types , I'll introduce them later .
operation
go The numerical operation of is similar to that of other languages .
Integers cannot be divided by 0, Floating point division 0 You'll get +Inf
and -Inf
, And floating point 0 except 0 You'll get NaN
.
The comparison of floating-point numbers is imprecise .
Plural type
I didn't know it until today go There are plural types , Namely complex64
and complex128
.
I feel that this type may never be used , Don't learn it .
Welcome to my WeChat official account. Notes on Jiangda
边栏推荐
- P3047 [usaco12feb]nearby cows g (tree DP)
- Data governance: metadata management
- esRally国内安装使用避坑指南-全网最新
- 解决方案:智慧工地智能巡检方案视频监控系统
- 链表面试题(图文详解)
- Three treasures of leeks and Chinese men's football team
- 【Redis】NoSQL数据库和redis简介
- 07- [istio] istio destinationrule (purpose rule)
- TS类型体操 之 字符串的妙用
- How to estimate the number of threads
猜你喜欢
Generator Foundation
Solution: système de surveillance vidéo intelligent de patrouille sur le chantier
Opencv learning notes 9 -- background modeling + optical flow estimation
[nonlinear control theory]9_ A series of lectures on nonlinear control theory
Related operations of Excel
Simulation of holographic interferogram and phase reconstruction of Fourier transform based on MATLAB
[cf gym101196-i] waif until dark network maximum flow
智能终端设备加密防护的意义和措施
opencv学习笔记八--答题卡识别
TS 类型体操 之 extends,Equal,Alike 使用场景和实现对比
随机推荐
08- [istio] istio gateway, virtual service and the relationship between them
Simulation of Teman green interferometer based on MATLAB
Secure captcha (unsafe verification code) of DVWA range
[cf gym101196-i] waif until dark network maximum flow
Ali's redis interview question is too difficult, isn't it? I was pressed on the ground and rubbed
[window] when the Microsoft Store is deleted locally, how to reinstall it in three steps
Oracle time display adjustment
opencv学习笔记九--背景建模+光流估计
P3047 [usaco12feb]nearby cows g (tree DP)
In the era of digital economy, how to ensure security?
How to delete all the words before or after a symbol in word
Scala语言学习-08-抽象类
TS 类型体操 之 循环中的键值判断,as 关键字使用
edge瀏覽器 路徑獲得
shu mei pai
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
Iterator Foundation
File upload of DVWA range
How to prevent Association in cross-border e-commerce multi account operations?
On why we should program for all