September 2019
Intermediate to advanced
816 pages
18h 47m
English
Let's consider two signed integers, Integer.MIN_VALUE (-2,147,483,648) and Integer.MAX_VALUE (2,147,483,647). Comparing these integers (signed values) will result in -2,147,483,648 being smaller than 2,147,483,647:
// resultSigned is equal to -1 indicating that// MIN_VALUE is smaller than MAX_VALUEint resultSigned = Integer.compare(Integer.MIN_VALUE, Integer.MAX_VALUE);
In JDK 8, these two integers can be compared as unsigned values via the Integer.compareUnsigned() method (this is the equivalent of Integer.compare() for unsigned values). Mainly, this method ignores the notion of sign bit, and the left-most bit is considered the most significant bit. Under the unsigned values umbrella, this method returns ...