简体   繁体   English

C ++到Java代码的转换

[英]C++ to Java Code Conversion

I have in C++ 我有C ++

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

So in Java 所以在Java中

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

but what is the meaning of the caret symbol? 但是插入符号的含义是什么? msk also will contain hexadecimal values. msk也将包含十六进制值。 I know the caret symbol is a type of pointer in C++ but not sure what it is doing here. 我知道插入符号是C ++中的一种指针,但不确定它在做什么。 Please explain. 请解释。

The ^ symbol represents the bitwise XOR operator in C, C++. ^符号表示C,C ++中按位XOR运算符。 List of operators in C, C++ . C,C ++中的运算符列表

The same operator is available for Java as well. 同样的运算符也可用于Java。 XOR Operator in Java . Java中的XOR运算符

The caret means bitwise XOR 插入符号表示按位XOR

The caret does NOT mean a kind of pointer in C++ (though MSVC++ has extension for C++/CLI that use that symbol) 插入符号并不意味着一种指针在C ++(虽然MSVC ++具有扩展C ++ / CLI使用该符号)

Caret symbol in C++ means XOR logical operation. C ++中的插入符号表示XOR逻辑运算。 Meaning for the code 0xFF ^ msk; 代码含义为0xFF ^ msk; is that you take bits in msk and invert them (zeroes to ones and vice versa) 是您在msk中取位并将其反转(零到1,反之亦然)

克拉符号是xor运算符,请参见此处

The ^ is bitwise XOR. ^是按位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). 如果您使用的是C ++ / CLI,那么它也是一种参考 (句柄)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM