前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【Go】Go语言基本数据类型

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

作者头像
Regan Yue
发布2021-09-16 11:06:47
2670
发布2021-09-16 11:06:47
举报
文章被收录于专栏:ReganYue's BlogReganYue's Blog

整型

  • 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.
代码语言:javascript
复制
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",'岳')

}
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021-02-07 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 整型
  • 浮点型
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档