Skip to content
Prev Previous commit
Next Next commit
#109: Simply convert to uint32 (long) value using a bit mask
  • Loading branch information
xerial committed Jun 30, 2014
commit 64d397ca19d05c8d3328e3aa984af97c893c890c
10 changes: 5 additions & 5 deletions msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ public long unpackLong() throws IOException {
case Code.UINT32: // unsigned int 32
int u32 = readInt();
if(u32 < 0) {
return (long) (u32 & 0x7fffffff) + 0x80000000L;
return u32 & 0xffffffffL;
} else {
return (long) u32;
}
Expand Down Expand Up @@ -814,7 +814,7 @@ public BigInteger unpackBigInteger() throws IOException {
case Code.UINT32: // unsigned int 32
int u32 = readInt();
if(u32 < 0) {
return BigInteger.valueOf((long) (u32 & 0x7fffffff) + 0x80000000L);
return BigInteger.valueOf(u32 & 0xffffffffL);
} else {
return BigInteger.valueOf((long) u32);
}
Expand Down Expand Up @@ -890,7 +890,7 @@ public void unpackInteger(IntegerHolder holder) throws IOException {
case Code.UINT32: // unsigned int 32
int u32 = readInt();
if(u32 < 0) {
holder.setLong((long) (u32 & 0x7fffffff) + 0x80000000L);
holder.setLong(u32 & 0xffffffffL);
} else {
holder.setInt(u32);
}
Expand Down Expand Up @@ -1225,7 +1225,7 @@ private static MessageIntegerOverflowException overflowU16(short u16) {
}

private static MessageIntegerOverflowException overflowU32(int u32) {
BigInteger bi = BigInteger.valueOf((long) (u32 & 0x7fffffff) + 0x80000000L);
BigInteger bi = BigInteger.valueOf(u32 & 0xffffffffL);
return new MessageIntegerOverflowException(bi);
}

Expand All @@ -1250,7 +1250,7 @@ private static MessageIntegerOverflowException overflowI64(long i64) {
}

private static MessageSizeException overflowU32Size(int u32) {
long lv = (long) (u32 & 0x7fffffff) + 0x80000000L;
long lv = u32 & 0xffffffffL;
return new MessageSizeException(lv);
}

Expand Down