Home » Java Integer toUnsignedLong() method with Examples

Java Integer toUnsignedLong() method with Examples

by Online Tutorials Library

Java Integer toUnsignedLong() Method

The toUnsignedLong() is a Java Integer class method which converts the argument to a long by an unsigned conversion. In an unsigned conversion to a long, the high-order 32 bits of the long are zero and the low-order 32 bits are equal to the bits of the integer argument.

Syntax:

Following is the declaration of toUnsignedLong() method:

Parameter:

DataType Parameter Description Required/Optional
int i It is a value which is used to convert to an unsigned long. Required

Returns:

The toUnsignedLong() method returns the argument converted to long by an unsigned conversion.

Exceptions:

NA

Compatibility Version:

Java 1.8 and above

Example 1

Test it Now

Output:

Unsigned x1  = 4294967291  Unsigned x2  = 5  Unsigned y1  = 4294967290  Unsigned y2  = 6  

Example 2

Output:

Enter a value to perform unsigned operation: 32435  Output: 32435  

Example 3

Output:

Input value to perform unsigned operation: -GSDJD  Exception in thread "main" java.util.InputMismatchException  at java.base/java.util.Scanner.throwFor(Scanner.java:939)  at java.base/java.util.Scanner.next(Scanner.java:1594)  at java.base/java.util.Scanner.nextInt(Scanner.java:2258)  at java.base/java.util.Scanner.nextInt(Scanner.java:2212)  at myPackage.IntegerToUnsignedLongExample3.main(IntegerToUnsignedLongExample3.java:8)  

Next TopicvalueOf() Method

You may also like