VB.NET computes differently with Java

Can someone explain to me why .net computes them differently with Java

The equation

(-1646490243 << 4) + 3333 ^ -1646490243 + -957401312 ^ (-1646490243 >> 5) + 4 

Java calculates it as

 1173210151 

.Net is calculated as

 -574040108 

My problem is that I need .Net to calculate the same thing as Java, since I pass through the decryption function, and if it calculates differently, then the decryption will not be correct.

Any help would be appreciated.

- Update -

Thanks guys, Hor was what I had to use. Plus you need to bypass Java without throwing an exception when the Integer number is too large.

Xor gives the result -3121757145

 (-1646490243 << 4) + 3333 Xor -1646490243 + -957401312 Xor (-1646490243 >> 5) + 4 

Combine this with the answer from this link I found - Java sum 2 negative numbers . Gets the same result as Java

 -3121757145 + 2 ^ 32 = 1173210151 
+6
source share
1 answer

I checked the operator precedence table for Java and Visual Basic , they are the same with respect to the operators in the expression. So this is not a priority issue.

Keep in mind that in Visual Basic ^ there is an operator for exponentiation , while Xor is an operator for exclusive or . This is different from Java, which uses the ^ operator as exceptional and does not have an operator for exponentiation. All other operators in the expression are the same in both languages

I can’t tell from the code whether the fragment is in Java or in Visual Basic - I assume it is in Java. If so, it is entirely possible that you are confusing exclusive or; try replacing ^ with Xor in Visual Basic code and see if this fixes the problem:

 (-1646490243 << 4) + 3333 Xor -1646490243 + -957401312 Xor (-1646490243 >> 5) + 4 
+3
source

All Articles