Files
go_test/4.基本数据类型.go

38 lines
748 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package main
import "fmt"
func main() {
type_()
}
func type_() {
var age int = 12 // 设定类型为数字
fmt.Println(age)
var text = "Hello mfk\n" // 自动识别类型
fmt.Printf(text)
// uint + x
// x 是比特的位数
var u8 uint8 = 255
// 0 0 0 0 0 0 0 0 = 0
// 1 1 1 1 1 1 1 1 = 2^8-1=255
fmt.Println(u8)
// int8 支持正负数
// 0 0 0 0 0 0 0 0 = 1
// 0 1 1 1 1 1 1 1 = 2^(8-1)-1=127 // 一个比特位区分正负了
// 1 0 0 0 0 0 0 1 = -1 负数的最大值
// 1 0 0 0 0 0 0 0 = -128
//######################################################
// 源码 补码 (取反=反码+1听不懂标记一下下次学
//######################################################
}