We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
An 8 bit mask may be needed
https://github.com/fiji/IO/blob/1fa709937a44b369c3d56545cea191f0b0b821ed/src/main/java/sc/fiji/io/icns/IOSupport.java
Line 104: return ((data[0] & 0xFF) << 8) + data[1];
should have an 8 bit mask & operation added: return ((data[0] & 0xFF) << 8) + (data[1] & 0xff);
This eliminates sign extension issue.
This snippet I think exemplifies the fix:
byte[] data = new byte[2]; data[0] = (byte)0x80; data[1] = (byte)0x80; long incorrect = ((data[0] & 0xff) << 8) + (data[1]); System.out.println("Incorrect " + String.format("0x%08X", incorrect)); long correct = ((data[0] & 0xff) << 8) + (data[1] & 0xff); System.out.println("correct " + String.format("0x%08X", correct));
Output:
Incorrect 0x00007F80 correct 0x00008080
The text was updated successfully, but these errors were encountered:
No branches or pull requests
An 8 bit mask may be needed
https://github.com/fiji/IO/blob/1fa709937a44b369c3d56545cea191f0b0b821ed/src/main/java/sc/fiji/io/icns/IOSupport.java
Line 104:
return ((data[0] & 0xFF) << 8) + data[1];
should have an 8 bit mask & operation added:
return ((data[0] & 0xFF) << 8) + (data[1] & 0xff);
This eliminates sign extension issue.
This snippet I think exemplifies the fix:
Output:
Incorrect 0x00007F80
correct 0x00008080
The text was updated successfully, but these errors were encountered: