Function: returns an unsigned byte array.
public static long bytesToDec(byte[] byteArray) { long total = 0; for(int i = 0 ; i < byteArray.length ; i++) { int temp = byteArray[i]; if(temp < 0) { total += (128 + (byteArray[i] & 0x7f)) * Math.pow(2, (byteArray-1-i)*8); } else { total += ((byteArray[i] & 0x7f) * Math.pow(2, (byteArray-1-i)*8)); } } return total; }
source share