开发者

C++ to Java Code Conversion

开发者 https://www.devze.com 2023-03-06 06:31 出处:网络
I have in C++ r.bits[k] &= 0xFF ^ msk; So in Java r.bits[k] = r.bits[k] & 0xFF, but what is the meaning of the caret symbol? msk also will contain hexadecimal values.

I have in C++

r.bits[k] &= 0xFF ^ msk;

So in Java

r.bits[k] = r.bits[k] & 0xFF,

but what is the meaning of the caret symbol? msk also will contain hexadecimal values. 开发者_运维问答I know the caret symbol is a type of pointer in C++ but not sure what it is doing here. Please explain.


The ^ symbol represents the bitwise XOR operator in C, C++. List of operators in C, C++.

The same operator is available for Java as well. XOR Operator in Java.


The caret means bitwise XOR

The caret does NOT mean a kind of pointer in C++ (though MSVC++ has extension for C++/CLI that use that symbol)


Caret symbol in C++ means XOR logical operation. Meaning for the code 0xFF ^ msk; is that you take bits in msk and invert them (zeroes to ones and vice versa)


The carat symbol is the xor operator see here


The ^ is bitwise XOR.

For example:

1 ^ 1 = 0
2 ^ 1 = 3
0 ^ 1 = 1

If you are using C++/CLI then it is also a kind of reference (handle).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号