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

Print this page
rev 6151 : imported patch reducers


 514     /**
 515      * Converts the argument to a {@code long} by an unsigned
 516      * conversion.  In an unsigned conversion to a {@code long}, the
 517      * high-order 48 bits of the {@code long} are zero and the
 518      * low-order 16 bits are equal to the bits of the {@code short} argument.
 519      *
 520      * Consequently, zero and positive {@code short} values are mapped
 521      * to a numerically equal {@code long} value and negative {@code
 522      * short} values are mapped to a {@code long} value equal to the
 523      * input plus 2<sup>16</sup>.
 524      *
 525      * @param  x the value to convert to an unsigned {@code long}
 526      * @return the argument converted to {@code long} by an unsigned
 527      *         conversion
 528      * @since 1.8
 529      */
 530     public static long toUnsignedLong(short x) {
 531         return ((long) x) & 0xffffL;
 532     }
 533 










































 534     /** use serialVersionUID from JDK 1.1. for interoperability */
 535     private static final long serialVersionUID = 7515723908773894738L;
 536 }


 514     /**
 515      * Converts the argument to a {@code long} by an unsigned
 516      * conversion.  In an unsigned conversion to a {@code long}, the
 517      * high-order 48 bits of the {@code long} are zero and the
 518      * low-order 16 bits are equal to the bits of the {@code short} argument.
 519      *
 520      * Consequently, zero and positive {@code short} values are mapped
 521      * to a numerically equal {@code long} value and negative {@code
 522      * short} values are mapped to a {@code long} value equal to the
 523      * input plus 2<sup>16</sup>.
 524      *
 525      * @param  x the value to convert to an unsigned {@code long}
 526      * @return the argument converted to {@code long} by an unsigned
 527      *         conversion
 528      * @since 1.8
 529      */
 530     public static long toUnsignedLong(short x) {
 531         return ((long) x) & 0xffffL;
 532     }
 533 
 534     /**
 535      * Adds two {@code short} values together as per the + operator.
 536      * Suitable for conversion as a method reference to functional interfaces such
 537      * as {@code BinaryOperator&lt;Short&gt;}.
 538      *
 539      * @param   a   an argument.
 540      * @param   b   another argument.
 541      * @return  the sum of {@code a} and {@code b}.
 542      * @since 1.8
 543      */
 544     public static short sum(short a, short b) {
 545         return (short) (a + b);
 546     }
 547 
 548     /**
 549      * Returns the greater of two {@code short} values.
 550      * Suitable for conversion as a method reference to functional interfaces such
 551      * as {@code BinaryOperator&lt;Short&gt;}.
 552      *
 553      * @param   a   an argument.
 554      * @param   b   another argument.
 555      * @return  the larger of {@code a} and {@code b}.
 556      * @since 1.8
 557      */
 558     public static short max(short a, short b) {
 559         return (a >= b) ? a : b;
 560     }
 561 
 562     /**
 563      * Returns the lesser of two {@code short} values.
 564      * Suitable for conversion as a method reference to functional interfaces such
 565      * as {@code BinaryOperator&lt;Short&gt;}.
 566      *
 567      * @param   a   an argument.
 568      * @param   b   another argument.
 569      * @return  the lesser of {@code a} and {@code b}.
 570      * @since 1.8
 571      */
 572     public static short min(short a, short b) {
 573         return (a <= b) ? a : b;
 574     }
 575 
 576     /** use serialVersionUID from JDK 1.1. for interoperability */
 577     private static final long serialVersionUID = 7515723908773894738L;
 578 }