public BigInteger unpackBigInteger ( ) throws IOException { byte b = readByte ( ) ; if ( Code . isFixInt ( b ) ) { return BigInteger . valueOf ( ( long ) b ) ; } switch ( b ) { case Code . UINT8 : // unsigned int 8 byte u8 = readByte ( ) ; return BigInteger . valueOf ( ( long ) ( u8 & 0xff ) ) ; case Code . UINT16 : // unsigned int 16 short u16 = readShort ( ) ; return BigInteger . valueOf ( ( long ) ( u16 & 0xffff ) ) ; case Code . UINT32 : // unsigned int 32 int u32 = readInt ( ) ; if ( u32 < 0 ) { return BigInteger . valueOf ( ( long ) ( u32 & 0x7fffffff ) + 0x80000000 L ) ; } else { return BigInteger . valueOf ( ( long ) u32 ) ; } case Code . UINT64 : // unsigned int 64 long u64 = readLong ( ) ; if ( u64 < 0L ) { BigInteger bi = BigInteger . valueOf ( u64 + Long . MAX_VALUE + 1L ) . setBit ( 63 ) ; return bi ; } else { return BigInteger . valueOf ( u64 ) ; } case Code . INT8 : // signed int 8 byte i8 = readByte ( ) ; return BigInteger . valueOf ( ( long ) i8 ) ; case Code . INT16 : // signed int 16 short i16 = readShort ( ) ; return BigInteger . valueOf ( ( long ) i16 ) ; case Code . INT32 : // signed int 32 int i32 = readInt ( ) ; return BigInteger . valueOf ( ( long ) i32 ) ; case Code . INT64 : // signed int 64 long i64 = readLong ( ) ; return BigInteger . valueOf ( i64 ) ; } throw unexpected ( "Integer" , b ) ; }
Reads a BigInteger .