java.lang.Short toUnsignedLong​(short x)

Description

The toUnsignedLong​(short x) method of Short class converts the argument to a long by an unsigned conversion. In an unsigned conversion to a long, the high-order 48 bits of the long are zero and the low-order 16 bits are equal to the bits of the short argument. Consequently, zero and positive short values are mapped to a numerically equal long value and negative short values are mapped to a long value equal to the input plus 216.

Make a note that the toUnsignedLong​​(short x) method of Short class is static thus it should be accessed statically. Mean to say the we would be calling this method in this format:

Non static method is usually called by just declaring method_name(argument) however in this case since the method is static, it should be called by appending the class name as suffix. We will be encountering a compilation problem if we call the java toUnsignedLong​​(short x)​ method non statically.

Method Syntax

public static long toUnsignedLong​(short x)

Method Argument

Data Type Parameter Description
short x the value to convert to an unsigned int

Method Returns

The toUnsignedLong​(short x) method of Short class returns the argument converted to long by an unsigned conversion

Compatibility

Requires Java 1.8 and up

Java Short toUnsignedLong​​(short x) Example

Below is a simple java example on the usage of toUnsignedLong​​(short x) method of Short class.

Sample Output

Below is the sample output when you run the above example.

Java Short toUnsignedLong​(short x) method example output

Suggested Reading List