Java Short Number Create toShort(byte mostSignificant, byte leastSignificant)

Here you can find the source of toShort(byte mostSignificant, byte leastSignificant)

Description

Converts a pair of bytes to a short

License

Open Source License

Parameter

Parameter Description
mostSignificant The most significant number part
leastSignificant The least significant number part

Return

A short

Declaration

public static short toShort(byte mostSignificant, byte leastSignificant) 

Method Source Code

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

public class Main {
    /**/*w  ww.  j  a  v  a 2  s. c  o m*/
     * Converts a pair of bytes to a {@code short}
     * @param mostSignificant The most significant number part
     * @param leastSignificant The least significant number part
     * @return A {@code short}
     */
    public static short toShort(byte mostSignificant, byte leastSignificant) {
        short n = 0;
        n ^= mostSignificant & 0xFF;
        n <<= 8;
        n ^= leastSignificant & 0xFF;
        return n;
    }
}

Related

  1. toShort(byte a, byte b)
  2. toShort(byte b0, byte b1)
  3. toShort(byte byte0, byte byte1)
  4. toShort(byte msb, byte lsb)
  5. toShort(byte... b)
  6. toShort(byte... b)
  7. toShort(byte[] b)