hola! por medio de mi socket TCP transmito un número sin signo que ocupa 8 bytes, el long no me sirve porque es con signo. Asi que estoy usando bigInteger.
En el cliente hago:
Código:
BigInteger big = new BigInteger("12254632286906037027");
/*byte[] enviar = new byte[] {
(byte)(0xaa),
(byte)(0x11),
(byte)(0x33),
(byte)(0x23),
(byte)(0x1a),
(byte)(0x11),
(byte)(0x33),
(byte)(0x23)
};*/
byte[] enviar = big.toByteArray();
Y en el servidor recibo así:
Código:
int IBUTLength = 8;
byte[] prueba = new byte[8];
for (int i = 0; i< IBUTLength; i++){
prueba[i] = (byte)dataInputStream.readUnsignedByte();
}
BigInteger big= new BigInteger(prueba);
System.out.println(big);
y me imprime con signo negativo
-6192111786803514589
¿Cómo puedo hacer para que no me pase esto? Gracias!