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