Java Byte - toUnsignedLong() Method
The java.lang.Byte.toUnsignedLong() method is used to convert the argument to a long by an unsigned conversion. In an unsigned conversion to a long, the high-order 56 bits of the long are zero and the low-order 8 bits are equal to the bits of the byte argument. Consequently, zero and positive byte values are mapped to a numerically equal long value and negative byte values are mapped to a long value equal to the input plus 28.
Syntax
public static long toUnsignedLong(byte x)
Parameters
x |
Specify the value to convert to an unsigned long. |
Return Value
Returns the argument converted to long by an unsigned conversion.
Exception
NA.
Example:
In the example below, the java.lang.Byte.toUnsignedLong() method is used to convert the given byte value to a long by an unsigned conversion.
import java.lang.*; public class MyClass { public static void main(String[] args) { //creating byte values byte x = 25; byte y = -25; //printing toUnsignedLong value of byte values System.out.println("toUnsignedLong value of x is: " + Byte.toUnsignedLong(x)); System.out.println("toUnsignedLong value of y is: " + Byte.toUnsignedLong(y)); } }
The output of the above code will be:
toUnsignedLong value of x is: 25 toUnsignedLong value of y is: 231
❮ Java.lang - Byte