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
It is possible to unpack ulong bigger than Long.MAX_VALUE correctly as BigInteger. But it is not possible to pack it correctly - it becomes unsigned.
public static void main(String[] args) throws IOException { byte[] pack = bytesInQuestion(); // correct unpacking BigInteger unpackValue = (BigInteger) MsgPackLite.INSTANCE.unpack(new ByteArrayInputStream(pack)); // let's pack it back again ByteArrayOutputStream out = new ByteArrayOutputStream(); MsgPackLite.INSTANCE.pack(unpackValue, out); byte[] repack = out.toByteArray(); System.out.println(Arrays.equals(pack, repack)); System.out.println(Arrays.toString(pack)); System.out.println(Arrays.toString(repack)); //false //[-49, -128, 0, 0, 0, 127, -1, -1, -2] //[-50, 127, -1, -1, -2] } private static byte[] bytesInQuestion() throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); DataOutputStream dataStream = new DataOutputStream(out); try { dataStream.write(MsgPackLite.INSTANCE.MP_UINT64); dataStream.writeLong(Long.MAX_VALUE + Integer.MAX_VALUE); return out.toByteArray(); } finally { dataStream.close(); } }
The text was updated successfully, but these errors were encountered:
msgpack-lite: fix BigInteger pack / unpack
f0b92cb
Fixes #27.
1f8b981
1e7fc18
No branches or pull requests
It is possible to unpack ulong bigger than Long.MAX_VALUE correctly as BigInteger. But it is not possible to pack it correctly - it becomes unsigned.
The text was updated successfully, but these errors were encountered: