int 前的插入符号是什么意思?
What does a caret before an int mean?
我知道插入符号 ^
表示按位异或
但我正在看一段 Go 代码,我看到了类似
的东西
input[0] = ^output[3]
例如,当我尝试时:
^1 gives -2
^2 gives -3
etc..
作为一元运算符,它意味着 'bitwise not'
来自语言规范的 "Arithmetic Operators" 部分:
For integer operands, the unary operators +, -, and ^ are defined as
follows:
+x is 0 + x
-x negation is 0 - x
^x bitwise complement is m ^ x with m = "all bits set to 1" for unsigned x
and m = -1 for signed x
我知道插入符号 ^
表示按位异或
但我正在看一段 Go 代码,我看到了类似
input[0] = ^output[3]
例如,当我尝试时:
^1 gives -2
^2 gives -3
etc..
作为一元运算符,它意味着 'bitwise not'
来自语言规范的 "Arithmetic Operators" 部分:
For integer operands, the unary operators +, -, and ^ are defined as follows:
+x is 0 + x -x negation is 0 - x ^x bitwise complement is m ^ x with m = "all bits set to 1" for unsigned x and m = -1 for signed x