< prev index next >

src/java.base/share/classes/java/lang/Short.java

Print this page
rev 12859 : 8033148: Lexicographic comparators for arrays
Reviewed-by: jrose, chegar, bchristi, mduigou
rev 12351 : 8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
Summary: Annotate possibly intrinsified methods with @HotSpotIntrinsicCandidate. Add checks omitted by intrinsics to the library code. Add CheckIntrinsics flags to check consistency of intrinsics.
Reviewed-by: jrose, kvn, thartmann, vlivanov, abuckley, darcy, ascarpino, briangoetz, alanb, aph, dnsimon
rev 10469 : 8054834: Modular Source Code
Reviewed-by: alanb, chegar, ihse, mduigou
Contributed-by: alan.bateman@oracle.com, alex.buckley@oracle.com, chris.hegarty@oracle.com, erik.joelsson@oracle.com, jonathan.gibbons@oracle.com, karen.kinnear@oracle.com, magnus.ihse.bursie@oracle.com, mandy.chung@oracle.com, mark.reinhold@oracle.com, paul.sandoz@oracle.com

*** 466,475 **** --- 466,491 ---- public static int compare(short x, short y) { return x - y; } /** + * Compares two {@code short} values numerically treating the values + * as unsigned. + * + * @param x the first {@code short} to compare + * @param y the second {@code short} to compare + * @return the value {@code 0} if {@code x == y}; a value less + * than {@code 0} if {@code x < y} as unsigned values; and + * a value greater than {@code 0} if {@code x > y} as + * unsigned values + * @since 9 + */ + public static int compareUnsigned(short x, short y) { + return Short.toUnsignedInt(x) - Short.toUnsignedInt(y); + } + + /** * The number of bits used to represent a {@code short} value in two's * complement binary form. * @since 1.5 */ public static final int SIZE = 16;
< prev index next >