Short.toUnsignedInt(): This method is available in java.lang.Short class of Java.
Syntax:
int java.lang.Short.toUnsignedInt(short x)
This method takes one argument of type short as its parameter. This method 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.
Note:
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.
Parameters: One parameter is required for this method.
x: the value to convert to an unsigned int.
Returns: the argument converted to int by an unsigned conversion.
Exceptions: NA
Approach
Java
public class ShorttoUnsignedInt {public static void main(String[] args) {short x = 12;System.out.println(Short.toUnsignedInt(x));}}
Output:
12
No comments:
Post a Comment