Java equivalent of unsigned long long?
Solution 1:
Starting Java 8, there is support for unsigned long (unsigned 64 bits). The way you can use it is:
Long l1 = Long.parseUnsignedLong("17916881237904312345");
To print it, you can not simply print l1, but you have to first:
String l1Str = Long.toUnsignedString(l1)
Then
System.out.println(l1Str);
Solution 2:
I don't believe so. Once you want to go bigger than a signed long, I think BigInteger is the only (out of the box) way to go.
Solution 3:
Nope, there is not. You'll have to use the primitive long
data type and deal with signedness issues, or use a class such as BigInteger
.