src/share/classes/java/lang/Integer.java

Print this page
rev 6190 : [mq]: reducers


1495     public static int signum(int i) {
1496         // HD, Section 2-7
1497         return (i >> 31) | (-i >>> 31);
1498     }
1499 
1500     /**
1501      * Returns the value obtained by reversing the order of the bytes in the
1502      * two's complement representation of the specified {@code int} value.
1503      *
1504      * @return the value obtained by reversing the bytes in the specified
1505      *     {@code int} value.
1506      * @since 1.5
1507      */
1508     public static int reverseBytes(int i) {
1509         return ((i >>> 24)           ) |
1510                ((i >>   8) &   0xFF00) |
1511                ((i <<   8) & 0xFF0000) |
1512                ((i << 24));
1513     }
1514 










































1515     /** use serialVersionUID from JDK 1.0.2 for interoperability */
1516     private static final long serialVersionUID = 1360826667806852920L;
1517 }


1495     public static int signum(int i) {
1496         // HD, Section 2-7
1497         return (i >> 31) | (-i >>> 31);
1498     }
1499 
1500     /**
1501      * Returns the value obtained by reversing the order of the bytes in the
1502      * two's complement representation of the specified {@code int} value.
1503      *
1504      * @return the value obtained by reversing the bytes in the specified
1505      *     {@code int} value.
1506      * @since 1.5
1507      */
1508     public static int reverseBytes(int i) {
1509         return ((i >>> 24)           ) |
1510                ((i >>   8) &   0xFF00) |
1511                ((i <<   8) & 0xFF0000) |
1512                ((i << 24));
1513     }
1514 
1515     /**
1516      * Adds two integers together as per the + operator.
1517      * Suitable for conversion as a method reference to functional interfaces such
1518      * as {@code BinaryOperator&lt;Integer&gt;} or {@code IntBinaryOperator}.
1519      *
1520      * @param   a   an argument.
1521      * @param   b   another argument.
1522      * @return  the sum of {@code a} and {@code b}.
1523      * @since 1.8
1524      */
1525     public static int sum(int a, int b) {
1526         return a + b;
1527     }
1528 
1529     /**
1530      * Returns the greater of two {@code int} values.
1531      * Suitable for conversion as a method reference to functional interfaces such
1532      * as {@code BinaryOperator&lt;Integer&gt;} or {@code IntBinaryOperator}.
1533      *
1534      * @param   a   an argument.
1535      * @param   b   another argument.
1536      * @return  the larger of {@code a} and {@code b}.
1537      * @since 1.8
1538      */
1539     public static int max(int a, int b) {
1540         return Math.max(a, b);
1541     }
1542 
1543     /**
1544      * Returns the lesser of two {@code int} values.
1545      * Suitable for conversion as a method reference to functional interfaces such
1546      * as {@code BinaryOperator&lt;Integer&gt;} or {@code IntBinaryOperator}.
1547      *
1548      * @param   a   an argument.
1549      * @param   b   another argument.
1550      * @return  the lesser of {@code a} and {@code b}.
1551      * @since 1.8
1552      */
1553     public static int min(int a, int b) {
1554         return Math.min(a, b);
1555     }
1556 
1557     /** use serialVersionUID from JDK 1.0.2 for interoperability */
1558     private static final long serialVersionUID = 1360826667806852920L;
1559 }