-
Notifications
You must be signed in to change notification settings - Fork 272
New issue
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
Optimizing ZipEightByteInteger #614
base: master
Are you sure you want to change the base?
Conversation
Hello @Glavo I believe this PR breaks the ZIP specification. The package may not be in full compliance either. Please rebase on git master to pick up In https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT, I read
This means the max value for an unsigned 8 byte field is WDYT? |
Done. This PR can pass this test.
We just need to use negative numbers to represent values greater than This is a standard practice, and |
I added some more tests to prove that |
Let me explain this in more detail. Although byte, short, int, and long are treated as signed by default, they are essentially just 1, 2, 4, or 8 bytes, and the specific semantics depends on what the user thinks they are. Since Java does not have unsigned integers, it is a common and standard practice to give unsigned semantics to byte, short, int, and long. A notable example is that JDK-4504839 and JDK-6322074 added methods to the standard library to help users more easily operate on these integer values with unsigned semantics. In addition, methods such as |
Use unsigned long instead of BigInteger to simplify code and improve performance.