【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",'岳')

}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ReganYue

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值