userid:= 12345
did:=(userid& ^(0xFFFF<< 48))
pre> 当编译这段代码时,我得到:
./ xxxx.go:511:常量-18446462598732840961溢出int
你知道什么是这件事情和如何解决它?
Thanks。
^(0xFFFF<< 48) 0xffff000000000000 -0xffff000000000001 userid:= 12345 userid int & -0xffff000000000001 int int
0x0000ffffffffffff 1 <48-1 int int64 int
博客文章 https://blog.golang.org/constants 解释了常量是如何工作的,以及一些背景知道他们是如何工作的。
userid := 12345
did := (userid & ^(0xFFFF << 48))
when compiling this code, I got:
./xxxx.go:511: constant -18446462598732840961 overflows int
Do you know what is the matter with this and how to solve it ? Thanks.
^(0xFFFF << 48)
0xffff << 480xffff000000000000-0xffff000000000001
userid := 12345useridint&-0xffff000000000001intint
0x0000ffffffffffff1<<48 - 1intint64int
The blog post https://blog.golang.org/constants explains how constants work, and some background on why they are the way they are.
这篇关于golang常数溢出uint64有什么问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!