600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > 【Go】Go语言基本数据类型

【Go】Go语言基本数据类型

时间:2019-05-25 17:16:54

相关推荐

【Go】Go语言基本数据类型

整型

int

// int is a signed integer type that is at least 32 bits in size. It is a distinct type, however, and not an alias for, say, int32.

int8: Range: -128 through 127.

int16: Range: -32768 through 32767.

int32(rune): Range: -2147483648 through 2147483647.

int64: Range: -9223372036854775808 through 9223372036854775807.

uint

// uint is an unsigned integer type that is at least 32 bits in size. It is a distinct type, however, and not an alias for, say, uint32.

uint8(byte): Range: 0 through 255.

uint16: Range: 0 through 65535.

uint32: Range: 0 through 4294967295.

uint64: Range: 0 through 18446744073709551615.

浮点型

float32:float32 is the set of all IEEE-754 32-bit floating-point numbers.float64:float64 is the set of all IEEE-754 64-bit floating-point numbers.

package mainimport "fmt"func main() {var v1=123fmt.Printf("v1的类型是%T\n",v1)var v2 int = 123fmt.Printf("v2的类型是%T\n",v2)var v3 float64 = 123fmt.Printf("v2的类型是%T\n",v3)var v4 = 123.0fmt.Printf("v2的类型是%T\n",v4)var v5 = "你好"fmt.Printf("v5的类型是%T\n",v5)var v6 = '岳'fmt.Printf("v6的类型是%T\n",v6)fmt.Printf("v6的值是%v\n",v6)fmt.Printf("v6的字符是%c\n",v6)fmt.Printf("23731的类型是%c\n",23731)var v7 = (100==(40+60))fmt.Printf("v7的类型是%T,值是%v\n",v7,v7)var v8 = ('岳'==23731)fmt.Printf("v8的类型是%T,值是%v\n",v8,v8)fmt.Printf("23731的字符形式是%c\n",23731)fmt.Printf("岳的数字形式是%d\n",'岳')fmt.Printf("岳在字符集中的序号是%d\n",'岳')}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。