Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to convert signed numbers into unsigned numbers in java
How to convert signed numbers into unsigned numbers in java
Code:

Public class ConvertToUnsigned {

private static short[]tempByteU = null; //bytes of unsigned data

public static short[]toGetUnsignedByte(byte[]a){

int len = a.length

tempByteU = new short[len];

for(int I = 0; I & ltlenI++) {// If the data is less than 0, AND the short data, the negative number is stored as the complement in the memory.

if(a[I]& lt; 0) {

tempByteU[I]=(short)(a[I]& amp; 0x 00 ff);

} else {// is greater than 0 and does not need to be changed.

tempByteU[I]= a[I];

}

}

Return tempByteU

}

}