【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 main

import "fmt"

func main()  {
    
    
	var v1=123
	fmt.Printf("v1的类型是%T\n",v1)

	var v2 int = 123
	fmt.Printf("v2的类型是%T\n",v2)

	var v3 float64 = 123
	fmt.Printf("v2的类型是%T\n",v3)

	var v4 = 123.0
	fmt.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",'岳')

}

猜你喜欢

转载自blog.csdn.net/qq_36045898/article/details/113742622