如何将int转换为int64?

huangapple go评论99阅读模式
英文:

How to change int into int64?

问题

我正在尝试将一个整数转换为go中的integer64,但是我没有成功。有人知道一个简单的方法吗?

英文:

Im trying to convert an integer into an integer64 in go but im having no luck. Anyone know an easy way to do this?

答案1

得分: 213

这被称为类型转换

i := 23
var i64 int64
i64 = int64(i)
英文:

This is called type conversion :

i := 23
var i64 int64
i64 = int64(i)

答案2

得分: 27

这可能很明显,但最简单的方法是:

i64 := int64(23)
英文:

This is probably obvious, but simplest:

i64 := int64(23)

答案3

得分: 3

i := 23
i64 := int64(i)
fmt.Printf("%T %T", i, i64) // 打印 i 和 i64 的数据类型

英文:
i := 23
i64 := int64(i)
fmt.Printf("%T %T", i, i64) // to print the data types of i and i64

huangapple
  • 本文由 发表于 2012年10月30日 18:47:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/13137365.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定