-
Enhancement
-
Resolution: Won't Fix
-
P4
-
5.0u4, 9, 10
-
sparc
-
generic
Java does not have primitives for unsigned integers.
Comparisons of unsigned quantities can be achieved by adding
MIN_VALUE to both sides of a signed inequality. For example:
public class ULong {
private long value;
public boolean gt(long ulong) {
return value + Long.MIN_VALUE > ulong + Long.MIN_VALUE;
}
}
When the machine architecture supports unsigned comparisions, as is
the case for SPARC, the compiler can recognize this idiom and utilize
the unsigned comparison instructions.
Note that the use of + in the method gt() above can correctly be replaced
with either - or ^. (The desired effect is the flipping of the sign bit.)
Comparisons of unsigned quantities can be achieved by adding
MIN_VALUE to both sides of a signed inequality. For example:
public class ULong {
private long value;
public boolean gt(long ulong) {
return value + Long.MIN_VALUE > ulong + Long.MIN_VALUE;
}
}
When the machine architecture supports unsigned comparisions, as is
the case for SPARC, the compiler can recognize this idiom and utilize
the unsigned comparison instructions.
Note that the use of + in the method gt() above can correctly be replaced
with either - or ^. (The desired effect is the flipping of the sign bit.)
- relates to
-
JDK-8317521 Enhance detection of integral unsigned comparisons
- Open