Java Unsigned Number Create unsignedShortToInt(final byte[] b)

Here you can find the source of unsignedShortToInt(final byte[] b)

Description

Converts a two byte array to an integer

License

Open Source License

Parameter

Parameter Description
b a byte array of length 2

Return

an int representing the unsigned short

Declaration

public static final int unsignedShortToInt(final byte[] b) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//from ww  w .  j  a v  a 2 s .  c  o  m
     * Converts a two byte array to an integer
     * 
     * @param b a byte array of length 2
     * @return an int representing the unsigned short
     */
    public static final int unsignedShortToInt(final byte[] b) {
        int i = 0;
        i |= b[0] & 0xFF;
        i <<= 8;
        i |= b[1] & 0xFF;
        return i;
    }
}

Related

  1. unsignedShort(short s)
  2. unsignedShort2Arr(int var, byte[] arrayBytes, int startIndex)
  3. unsignedShortAt(byte[] data, int pos)
  4. unsignedShortBytesToInt(byte[] b)
  5. unsignedShortToInt(byte[] b)
  6. unsignedShortToInt(short n)
  7. unsignedSubOverflow(int operand1, int operand2)
  8. unsignedToBytes(byte b)
  9. unsignedToSigned(int unsigned, int size)