Java Utililty Methods Short Number Create

List of utility methods to do Short Number Create

Description

The list of methods to do Short Number Create are organized into topic(s).

Method

shorttoShort(byte a, byte b)
to Short
return (short) (((a & 0x00ff) << 8) + (b & 0x00ff));
shorttoShort(byte b0, byte b1)
Returns a short built from two bytes.
return (short) (b0 & 0xFF | b1 << 8);
shorttoShort(byte byte0, byte byte1)
Constructs short given two bytes.
int hiByte = byte1 << 8;
int loByte = (byte0 << 24) >>> 24;
return (short) (hiByte | loByte);
shorttoShort(byte mostSignificant, byte leastSignificant)
Converts a pair of bytes to a short
short n = 0;
n ^= mostSignificant & 0xFF;
n <<= 8;
n ^= leastSignificant & 0xFF;
return n;
shorttoShort(byte msb, byte lsb)
Convert 2 bytes into a short.
return (short) ((0xff00 & (short) (msb << 8)) | (0x00ff & (short) lsb));
shorttoShort(byte... b)
to Short
return (short) toLong(b);
shorttoShort(byte... b)
to Short
return (short) toLong(b);
shorttoShort(byte[] b)
to Short
return toShort(b, 0);
shorttoShort(byte[] b)
Converts the first two bytes of b to a 16-bit signed integer.
return toShort(b, 0);
shorttoShort(byte[] b)
to Short
short s = 0;
short s0 = (short) (b[0] & 0xff);
short s1 = (short) (b[1] & 0xff);
s1 <<= 8;
s = (short) (s0 | s1);
return s;