< 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


 451 
 452     /**
 453      * Compares two {@code short} values numerically.
 454      * The value returned is identical to what would be returned by:
 455      * <pre>
 456      *    Short.valueOf(x).compareTo(Short.valueOf(y))
 457      * </pre>
 458      *
 459      * @param  x the first {@code short} to compare
 460      * @param  y the second {@code short} to compare
 461      * @return the value {@code 0} if {@code x == y};
 462      *         a value less than {@code 0} if {@code x < y}; and
 463      *         a value greater than {@code 0} if {@code x > y}
 464      * @since 1.7
 465      */
 466     public static int compare(short x, short y) {
 467         return x - y;
 468     }
 469 
 470     /**
















 471      * The number of bits used to represent a {@code short} value in two's
 472      * complement binary form.
 473      * @since 1.5
 474      */
 475     public static final int SIZE = 16;
 476 
 477     /**
 478      * The number of bytes used to represent a {@code short} value in two's
 479      * complement binary form.
 480      *
 481      * @since 1.8
 482      */
 483     public static final int BYTES = SIZE / Byte.SIZE;
 484 
 485     /**
 486      * Returns the value obtained by reversing the order of the bytes in the
 487      * two's complement representation of the specified {@code short} value.
 488      *
 489      * @param i the value whose bytes are to be reversed
 490      * @return the value obtained by reversing (or, equivalently, swapping)




 451 
 452     /**
 453      * Compares two {@code short} values numerically.
 454      * The value returned is identical to what would be returned by:
 455      * <pre>
 456      *    Short.valueOf(x).compareTo(Short.valueOf(y))
 457      * </pre>
 458      *
 459      * @param  x the first {@code short} to compare
 460      * @param  y the second {@code short} to compare
 461      * @return the value {@code 0} if {@code x == y};
 462      *         a value less than {@code 0} if {@code x < y}; and
 463      *         a value greater than {@code 0} if {@code x > y}
 464      * @since 1.7
 465      */
 466     public static int compare(short x, short y) {
 467         return x - y;
 468     }
 469 
 470     /**
 471      * Compares two {@code short} values numerically treating the values
 472      * as unsigned.
 473      *
 474      * @param  x the first {@code short} to compare
 475      * @param  y the second {@code short} to compare
 476      * @return the value {@code 0} if {@code x == y}; a value less
 477      *         than {@code 0} if {@code x < y} as unsigned values; and
 478      *         a value greater than {@code 0} if {@code x > y} as
 479      *         unsigned values
 480      * @since 9
 481      */
 482     public static int compareUnsigned(short x, short y) {
 483         return Short.toUnsignedInt(x) - Short.toUnsignedInt(y);
 484     }
 485 
 486     /**
 487      * The number of bits used to represent a {@code short} value in two's
 488      * complement binary form.
 489      * @since 1.5
 490      */
 491     public static final int SIZE = 16;
 492 
 493     /**
 494      * The number of bytes used to represent a {@code short} value in two's
 495      * complement binary form.
 496      *
 497      * @since 1.8
 498      */
 499     public static final int BYTES = SIZE / Byte.SIZE;
 500 
 501     /**
 502      * Returns the value obtained by reversing the order of the bytes in the
 503      * two's complement representation of the specified {@code short} value.
 504      *
 505      * @param i the value whose bytes are to be reversed
 506      * @return the value obtained by reversing (or, equivalently, swapping)


< prev index next >