Skip to content

Commit 26141a7

Browse files
committed
fixed ValueAccept.acceptUnsignedInteger
1 parent 7e3cd12 commit 26141a7

File tree

4 files changed

+5
-11
lines changed

4 files changed

+5
-11
lines changed

src/main/java/org/msgpack/unpacker/BigIntegerAccept.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,16 @@ void acceptUnsignedInteger(short v) {
5656
@Override
5757
void acceptUnsignedInteger(int v) {
5858
if(v < 0) {
59-
// FIXME
60-
this.value = BigInteger.valueOf(0xffffffffffffffffL + v + 1L);
59+
this.value = BigInteger.valueOf((long)(v & 0x7fffffff) + 0x80000000L);
6160
} else {
6261
this.value = BigInteger.valueOf((long)v);
6362
}
6463
}
6564

6665
@Override
6766
void acceptUnsignedInteger(long v) {
68-
if(v < 0) {
69-
this.value = BigInteger.valueOf(v+Long.MAX_VALUE+1).setBit(63);
67+
if(v < 0L) {
68+
this.value = BigInteger.valueOf(v+Long.MAX_VALUE+1L).setBit(63);
7069
} else {
7170
this.value = BigInteger.valueOf(v);
7271
}

src/main/java/org/msgpack/unpacker/LongAccept.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ void acceptUnsignedInteger(short v) {
5555
@Override
5656
void acceptUnsignedInteger(int v) {
5757
if(v < 0) {
58-
// FIXME
5958
this.value = (long)(v & 0x7fffffff) + 0x80000000L;
6059
} else {
6160
this.value = (long)v;

src/main/java/org/msgpack/unpacker/ValueAccept.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ void acceptUnsignedInteger(short v) {
6767
@Override
6868
void acceptUnsignedInteger(int v) {
6969
if(v < 0) {
70-
// FIXME
7170
long value = (long)(v & 0x7fffffff) + 0x80000000L;
7271
uc.write(ValueFactory.integerValue(value));
7372
} else {
@@ -78,7 +77,7 @@ void acceptUnsignedInteger(int v) {
7877
@Override
7978
void acceptUnsignedInteger(long v) {
8079
if(v < 0L) {
81-
BigInteger value = BigInteger.valueOf(0xffffffffffffffffL + v + 1L);
80+
BigInteger value = BigInteger.valueOf(v+Long.MAX_VALUE+1L).setBit(63);
8281
uc.write(ValueFactory.integerValue(value));
8382
} else {
8483
uc.write(ValueFactory.integerValue(v));

src/test/java/org/msgpack/TestBufferPackConvert.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,7 @@ public void testBigInteger(BigInteger v) throws Exception {
177177
BufferUnpacker unpacker = new BufferUnpacker();
178178
unpacker.wrap(bytes);
179179
Value value = unpacker.readValue();
180-
// FIXME assertTrue(value.isBigInteger());
181-
//System.out.println("## value: " + value.getClass());
182-
// following result is strange...
183-
//assertTrue(value.is??);
180+
assertTrue(value.isInteger());
184181
BigInteger ret = new Converter(value).readBigInteger();
185182
assertEquals(v, ret);
186183
}

0 commit comments

Comments
 (0)