< prev index next >

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

Print this page




 562      * Converts the argument to a {@code long} by an unsigned
 563      * conversion.  In an unsigned conversion to a {@code long}, the
 564      * high-order 48 bits of the {@code long} are zero and the
 565      * low-order 16 bits are equal to the bits of the {@code short} argument.
 566      *
 567      * Consequently, zero and positive {@code short} values are mapped
 568      * to a numerically equal {@code long} value and negative {@code
 569      * short} values are mapped to a {@code long} value equal to the
 570      * input plus 2<sup>16</sup>.
 571      *
 572      * @param  x the value to convert to an unsigned {@code long}
 573      * @return the argument converted to {@code long} by an unsigned
 574      *         conversion
 575      * @since 1.8
 576      */
 577     public static long toUnsignedLong(short x) {
 578         return ((long) x) & 0xffffL;
 579     }
 580 
 581     /** use serialVersionUID from JDK 1.1. for interoperability */

 582     private static final long serialVersionUID = 7515723908773894738L;
 583 }


 562      * Converts the argument to a {@code long} by an unsigned
 563      * conversion.  In an unsigned conversion to a {@code long}, the
 564      * high-order 48 bits of the {@code long} are zero and the
 565      * low-order 16 bits are equal to the bits of the {@code short} argument.
 566      *
 567      * Consequently, zero and positive {@code short} values are mapped
 568      * to a numerically equal {@code long} value and negative {@code
 569      * short} values are mapped to a {@code long} value equal to the
 570      * input plus 2<sup>16</sup>.
 571      *
 572      * @param  x the value to convert to an unsigned {@code long}
 573      * @return the argument converted to {@code long} by an unsigned
 574      *         conversion
 575      * @since 1.8
 576      */
 577     public static long toUnsignedLong(short x) {
 578         return ((long) x) & 0xffffL;
 579     }
 580 
 581     /** use serialVersionUID from JDK 1.1. for interoperability */
 582     @java.io.Serial
 583     private static final long serialVersionUID = 7515723908773894738L;
 584 }
< prev index next >