当前位置:网站首页>[Yugong series] go teaching course 010 in July 2022 - Boolean and character types of data types
[Yugong series] go teaching course 010 in July 2022 - Boolean and character types of data types
2022-07-29 10:02:00 【Yugong move code】
List of articles
One 、 Summary of data types
go There are four data types in the language : The base type , The compound type , Reference type , Interface type .
| type | name | length | Zero value | explain |
|---|---|---|---|---|
| bool | Boolean type | 1 | false | If its value is not true, it is false , It can't be represented by numbers true or false |
| byte | Byte type | 1 | 0 | uint8 Alias |
| rune | Character type | 4 | 0 | Dedicated to storage unicode code , Equivalent to uint32 |
| int, uint | integer | 4 or 8 | 0 | A signed 32 Bit or unsigned 64 position |
| int8 | integer | 1 | 0 | -128~ 127, |
| uint8 | integer | 1 | 0 | 0~ 255 |
| int16 | integer | 2 | 0 | -32768 ~ 32767, |
| uint16 | integer | 2 | 0 | 0 ~ 65535 |
| int32 | integer | 4 | 0 | -2147483648 To 2147483647 |
| uint32 | integer | 4 | 0 | 0 To 4294967295(42 Billion ) |
| int64 | integer | 8 | 0 | -9223372036854775808 To 9223372036854775807 |
| uint64 | integer | 8 | 0 | 0 To 18446744073709551615 ( 1844 Beijing ) |
| float32 | floating-point | 4 | 0.0 | Decimal places are accurate to 7 position |
| float64 | floating-point | 8 | 0.0 | Decimal places are accurate to 15 position |
| complex64 | Plural type | 8 | ||
| complex128 | Plural type | 16 | 64 Bit real number and imaginary number | |
| uintptr | integer | 4 or 8 | Enough to store pointers uint32 or uint64 Integers | |
| strina | character string | "” | utf-8 character string |
Two 、 Boolean type
stay Go In language , With keywords bool To declare Boolean types . Boolean types have only true and false Two values .
package main
import "fmt"
func main() {
var a bool
a = true
fmt.Println(a)
fmt.Printf("%t", a)
}

3、 ... and 、 Character type
Go In language , Each element of a string is called a character , It is mainly divided into the following two types :
- uint8 type , Or call it byte type , On behalf of ASCII A character of a code .
- rune type , Represents a UTF-8 character . Usually , When you need to deal with Chinese 、 Japanese 、 Korean and other compound characters , Need to use rune type .
package main
import "fmt"
func main() {
var a byte = 'q'
fmt.Printf("%d %T\n", a, a) // byte The actual type of is actually uint8, Corresponding ASCII Encoded as 113
var b rune = ' dog '
fmt.Printf("%d %T\n", b, b) // rune The actual type of is actually int32, Corresponding Unicode Encoded as 29356
}

边栏推荐
- [FPGA tutorial case 19] factorial operation through multiplier
- Youboxun, the gold donor of the open atom open source foundation, joined hands with partners to help openharmony break the circle!
- What kind of framework is friendly to developers?
- [fortran]vscode configure FORTRAN to run Hello World
- Sed, regular expression of shell programming
- How to integrate Google APIs with Google's application system (3) -- call the restful service of Google discovery API
- Sublime Text3 set different indents for different files
- 网络图片转换本地图片 - 默认值或快捷键
- The function of that sentence
- 这是一份不完整的数据竞赛年鉴!
猜你喜欢

综合设计一个OPPE主页--页面的底部

尹伊:我的学习成长路径

Some suggestions for programmers to leave single

English语法_不定代词 - 常用短语

Where are those test / development programmers in their 30s? a man should be independent at the age of thirty......

QoS quality of service five traffic shaping of QoS boundary behavior

根据给定字符数和字符,打印输出“沙漏”和剩余数

This developer, who has been on the list for four consecutive weeks, has lived like a contemporary college student

A little knowledge ~ miscellaneous notes on topics ~ a polymorphic problem

Excel tool for generating database table structure
随机推荐
Print out the "hourglass" and the remaining number according to the given number of characters and characters
数据可视化的利器-Seaborn简易入门
Function - (C travel notes)
待人宽容大度
JS 实现全屏效果
CS research assurance experience in 2021 (VI): system filling + some thoughts
Detailed explanation: what is the GPS Beidou time service server?
In simple terms, dependency injection and its application in Tiktok live broadcast
Tips of Day1 practice in 2022cuda summer training camp
QoS quality of service five traffic shaping of QoS boundary behavior
On memory computing integrated chip technology
Hanyuan high tech Gigabit 2-optical 6-conductor rail managed Industrial Ethernet switch supports X-ring redundant ring network one key ring network switch
Be tolerant and generous
一知半解 ~题目杂记 ~ 一个多态问题
TCP failure model
汉源高科千兆2光6电导轨式网管型工业级以太网交换机支持X-Ring冗余环网一键环网交换机
Shell notes (super complete)
This developer, who has been on the list for four consecutive weeks, has lived like a contemporary college student
关系型数据库之MySQL8——由内而外的深化全面学习
Several common design methods of test cases [easy to understand]