I'm trying to convert this snippet from C# to java. The C# snippet is correctly returning the value 3259945, the java code is incorrectly returning -16855. I'm completely useless at bit manipulation and have no idea where to even start. Can anyone help?
If people need the input variables I'll try to get the buffer byte array as a hex string so I can put it up. The startIndex I'm using is 26.
C# snippet:
Int64 mantissa = ((Int64)(buffer[startIndex] & 0x7F) << (8 * 2))
| ((Int64)buffer[startIndex + 3] << (8 * 1))
| ((Int64)buffer[startIndex + 2] << (8 * 0));
Java Snippet:
long mantissa = ((long)(buffer[startIndex] & 0x7F) << (8 * 2))
| ((long)buffer[startIndex + 3] << (8 * 1))
| ((long)buffer[startIndex + 2] << (8 * 0));
longinstead ofInt64?bufferisbyte[]? Take care that in Java bytes are signedInt64islong.Int64is the actual struct name andlongis just an alias.The startIndex is 26. However, without knowing what is inbufferthis code cannot be run. Could you provide the values forbuffer[startIndex],buffer[startIndex + 3], andbuffer[startIndex + 2]when you get the result3259945?