Java Byte Array Little Endian BytesLEToShort(final byte[] buf)

Here you can find the source of BytesLEToShort(final byte[] buf)

Description

Bytes LE To Short

License

Creative Commons License

Declaration

public final static short BytesLEToShort(final byte[] buf) 

Method Source Code

//package com.java2s;
//License from project: Creative Commons License 

public class Main {
    public final static short BytesLEToShort(final byte[] buf) {
        short val = 0x0;

        for (int i = 0; i < buf.length; i++) {
            val += ((short) buf[i] & 0xFF) << (8 * i);
        }/*from  ww  w . j  a  v  a 2 s . c o m*/

        return val;
    }
}

Related

  1. bytesLE2ushorts(byte[] b)
  2. BytesLEToFloat(final byte[] value)
  3. bytesLittleToFloat(byte[] data, int start)
  4. bytesLittleToLong(byte[] data, int start)
  5. bytesLittleToShort(byte[] data, int start)