1114 * @see Math#floorMod(long, long) 1115 * @see StrictMath#floorDiv(long, long) 1116 * @since 1.8 1117 */ 1118 public static long floorMod(long x, long y) { 1119 return Math.floorMod(x, y); 1120 } 1121 1122 /** 1123 * Returns the absolute value of an {@code int} value. 1124 * If the argument is not negative, the argument is returned. 1125 * If the argument is negative, the negation of the argument is returned. 1126 * 1127 * <p>Note that if the argument is equal to the value of 1128 * {@link Integer#MIN_VALUE}, the most negative representable 1129 * {@code int} value, the result is that same value, which is 1130 * negative. 1131 * 1132 * @param a the argument whose absolute value is to be determined. 1133 * @return the absolute value of the argument. 1134 */ 1135 public static int abs(int a) { 1136 return Math.abs(a); 1137 } 1138 1139 /** 1140 * Returns the absolute value of a {@code long} value. 1141 * If the argument is not negative, the argument is returned. 1142 * If the argument is negative, the negation of the argument is returned. 1143 * 1144 * <p>Note that if the argument is equal to the value of 1145 * {@link Long#MIN_VALUE}, the most negative representable 1146 * {@code long} value, the result is that same value, which 1147 * is negative. 1148 * 1149 * @param a the argument whose absolute value is to be determined. 1150 * @return the absolute value of the argument. 1151 */ 1152 public static long abs(long a) { 1153 return Math.abs(a); 1154 } 1155 1156 /** 1157 * Returns the absolute value of a {@code float} value. 1158 * If the argument is not negative, the argument is returned. 1159 * If the argument is negative, the negation of the argument is returned. 1160 * Special cases: 1161 * <ul><li>If the argument is positive zero or negative zero, the 1162 * result is positive zero. 1163 * <li>If the argument is infinite, the result is positive infinity. 1164 * <li>If the argument is NaN, the result is NaN.</ul> 1165 * 1166 * @apiNote As implied by the above, one valid implementation of 1167 * this method is given by the expression below which computes a 1168 * {@code float} with the same exponent and significand as the 1169 * argument but with a guaranteed zero sign bit indicating a 1170 * positive value: <br> 1171 * {@code Float.intBitsToFloat(0x7fffffff & Float.floatToRawIntBits(a))} 1172 * 1173 * @param a the argument whose absolute value is to be determined | 1114 * @see Math#floorMod(long, long) 1115 * @see StrictMath#floorDiv(long, long) 1116 * @since 1.8 1117 */ 1118 public static long floorMod(long x, long y) { 1119 return Math.floorMod(x, y); 1120 } 1121 1122 /** 1123 * Returns the absolute value of an {@code int} value. 1124 * If the argument is not negative, the argument is returned. 1125 * If the argument is negative, the negation of the argument is returned. 1126 * 1127 * <p>Note that if the argument is equal to the value of 1128 * {@link Integer#MIN_VALUE}, the most negative representable 1129 * {@code int} value, the result is that same value, which is 1130 * negative. 1131 * 1132 * @param a the argument whose absolute value is to be determined. 1133 * @return the absolute value of the argument. 1134 * @see Math#absExact(int) 1135 */ 1136 public static int abs(int a) { 1137 return Math.abs(a); 1138 } 1139 1140 /** 1141 * Returns the mathematical absolute value of an {@code int} value 1142 * if it is exactly representable as an {@code int}, throwing 1143 * {@code ArithmeticException} if the result overflows the 1144 * positive {@code int} range. 1145 * 1146 * <p>Since the range of two's complement integers is asymmetric 1147 * with one additional negative value, the mathematical absolute 1148 * value of {@link Integer#MIN_VALUE} overflows the positive 1149 * {@code int} range, so an exception is thrown for that argument. 1150 * 1151 * @param a the argument whose absolute value is to be determined 1152 * @return the absolute value of the argument, unless overflow occurs 1153 * @throws ArithmeticException if the argument is {@link Integer#MIN_VALUE} 1154 * @see Math#abs(int) 1155 * @since 15 1156 */ 1157 public static int absExact(int a) { 1158 return Math.absExact(a); 1159 } 1160 1161 /** 1162 * Returns the absolute value of a {@code long} value. 1163 * If the argument is not negative, the argument is returned. 1164 * If the argument is negative, the negation of the argument is returned. 1165 * 1166 * <p>Note that if the argument is equal to the value of 1167 * {@link Long#MIN_VALUE}, the most negative representable 1168 * {@code long} value, the result is that same value, which 1169 * is negative. 1170 * 1171 * @param a the argument whose absolute value is to be determined. 1172 * @return the absolute value of the argument. 1173 * @see Math#absExact(long) 1174 */ 1175 public static long abs(long a) { 1176 return Math.abs(a); 1177 } 1178 1179 /** 1180 * Returns the mathematical absolute value of an {@code long} value 1181 * if it is exactly representable as an {@code long}, throwing 1182 * {@code ArithmeticException} if the result overflows the 1183 * positive {@code long} range. 1184 * 1185 * <p>Since the range of two's complement integers is asymmetric 1186 * with one additional negative value, the mathematical absolute 1187 * value of {@link Long#MIN_VALUE} overflows the positive 1188 * {@code long} range, so an exception is thrown for that argument. 1189 * 1190 * @param a the argument whose absolute value is to be determined 1191 * @return the absolute value of the argument, unless overflow occurs 1192 * @throws ArithmeticException if the argument is {@link Long#MIN_VALUE} 1193 * @see Math#abs(long) 1194 * @since 15 1195 */ 1196 public static long absExact(long a) { 1197 return Math.absExact(a); 1198 } 1199 1200 /** 1201 * Returns the absolute value of a {@code float} value. 1202 * If the argument is not negative, the argument is returned. 1203 * If the argument is negative, the negation of the argument is returned. 1204 * Special cases: 1205 * <ul><li>If the argument is positive zero or negative zero, the 1206 * result is positive zero. 1207 * <li>If the argument is infinite, the result is positive infinity. 1208 * <li>If the argument is NaN, the result is NaN.</ul> 1209 * 1210 * @apiNote As implied by the above, one valid implementation of 1211 * this method is given by the expression below which computes a 1212 * {@code float} with the same exponent and significand as the 1213 * argument but with a guaranteed zero sign bit indicating a 1214 * positive value: <br> 1215 * {@code Float.intBitsToFloat(0x7fffffff & Float.floatToRawIntBits(a))} 1216 * 1217 * @param a the argument whose absolute value is to be determined |