SHARE
TWEET

Untitled

a guest May 19th, 2017 40 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     static public long getSigned(byte[] s) {
  2.         byte[] work = new byte[8];
  3.         for (int i = 0; i < s.length; i++) work[i] = s[i];
  4.         // check most significant bit sign
  5.         byte pad = ((s[s.length - 1] & 0x80) > 0) ? (byte) 0xFF : (byte) 0x00;
  6.         for (int i = s.length; i < 8; i++) work[i] = pad;
  7.        
  8.         return ByteBuffer.wrap(work).order(ByteOrder.LITTLE_ENDIAN).getLong();
  9.     }
RAW Paste Data
Top