我在代码库中看到了 ^0。
例子:
type stat struct {
...
min int64
...
}
newStat := stat{min: ^0}
^0 是什么意思?
最佳答案
根据the docs :
^x bitwise complement is m ^ x with m = "all bits set to 1" for
unsigned x and m = -1 for signed x
表示^0
与其他主流语言中的~0
相同。
在 two's complement 上(大多数编程语言采用)零补码的值为 -1(在有符号数据类型上)。所以这是一种写法:
newStat := stat{min: -1}
关于go - golang 中的 ^0 是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19170016/