java.lang.Short toUnsignedInt​(short x)

Description

The toUnsignedInt​(short x) method of Short class converts the argument to an int by an unsigned conversion. In an unsigned conversion to an int, the high-order 16 bits of the int 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 int value and negative short values are mapped to an int value equal to the input plus 216.

Make a note that the toUnsignedInt​(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 toUnsignedInt​(short x)​ method non statically.

Method Syntax

public static int toUnsignedInt​(short x)

Method Argument

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

Method Returns

The toUnsignedInt​(short x) method of Short class returns the value to convert to an unsigned int

Compatibility

Requires Java 1.8 and up

Java Short toUnsignedInt​(short x) Example

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

Sample Output

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

Java Short toUnsignedInt​(short x) method example output

Suggested Reading List