Java does not support unsigned integer types and the easiest way to represent an unsigned integer in Java is using a larger integer type.
DataInput interface does provide methods for reading unsigned integer types - readUnsignedByte
, which returns short
and readUnsignedShort
, which returns int
.
Why doesn't this interface have a readUnsignedInt
method that would return long
? Is there any particular reason?
Clarification: I'm aware of Java 8 support for unsigned arithmetic. The question is not how to deal with this problem, but why the DataInput
interface doesn't have such a method.