Byte.toUnsignedLong() in Java

Byte.toUnsignedLong(): This method is available in the java.lang.Byte class of Java.

Syntax:

long java.lang.Byte.toUnsignedLong(byte x)

This method takes one argument of type byte 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 56 bits of the long are zero and the low-order 8 bits are equal to the bits of the byte argument.

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.

For Example:

Byte.toUnsignedLong(1771) = > It returns 235.

Approach

Java

public class BytetoUnsignedLong {
    public static void main(String[] args) {

        byte x = (byte1771;
        System.out.println(Byte.toUnsignedLong(x));

    }
}

Output:

235

No comments:

Post a Comment