185 * @return a value with the magnitude of {@code magnitude} 186 * and the sign of {@code sign}. 187 * @author Joseph D. Darcy 188 * @deprecated Use Math.copySign. 189 */ 190 @Deprecated 191 public static float rawCopySign(float magnitude, float sign) { 192 return Math.copySign(magnitude, sign); 193 } 194 195 /* ***************************************************************** */ 196 197 /** 198 * Returns {@code true} if the argument is a finite 199 * floating-point value; returns {@code false} otherwise (for 200 * NaN and infinity arguments). 201 * 202 * @param d the {@code double} value to be tested 203 * @return {@code true} if the argument is a finite 204 * floating-point value, {@code false} otherwise. 205 */ 206 public static boolean isFinite(double d) { 207 return Math.abs(d) <= DoubleConsts.MAX_VALUE; 208 } 209 210 /** 211 * Returns {@code true} if the argument is a finite 212 * floating-point value; returns {@code false} otherwise (for 213 * NaN and infinity arguments). 214 * 215 * @param f the {@code float} value to be tested 216 * @return {@code true} if the argument is a finite 217 * floating-point value, {@code false} otherwise. 218 */ 219 public static boolean isFinite(float f) { 220 return Math.abs(f) <= FloatConsts.MAX_VALUE; 221 } 222 223 /** 224 * Returns {@code true} if the specified number is infinitely 225 * large in magnitude, {@code false} otherwise. 226 * 227 * <p>Note that this method is equivalent to the {@link 228 * Double#isInfinite(double) Double.isInfinite} method; the 229 * functionality is included in this class for convenience. 230 * 231 * @param d the value to be tested. 232 * @return {@code true} if the value of the argument is positive 233 * infinity or negative infinity; {@code false} otherwise. 234 */ 235 public static boolean isInfinite(double d) { 236 return Double.isInfinite(d); 237 } 238 239 /** 240 * Returns {@code true} if the specified number is infinitely 729 * Double.NEGATIVE_INFINITY)}; however, a 730 * {@code nextDown} implementation may run faster than its 731 * equivalent {@code nextAfter} call. 732 * 733 * <p>Special Cases: 734 * <ul> 735 * <li> If the argument is NaN, the result is NaN. 736 * 737 * <li> If the argument is negative infinity, the result is 738 * negative infinity. 739 * 740 * <li> If the argument is zero, the result is 741 * {@code -Double.MIN_VALUE} 742 * 743 * </ul> 744 * 745 * @param d starting floating-point value 746 * @return The adjacent floating-point value closer to negative 747 * infinity. 748 * @author Joseph D. Darcy 749 */ 750 public static double nextDown(double d) { 751 if( isNaN(d) || d == Double.NEGATIVE_INFINITY) 752 return d; 753 else { 754 if (d == 0.0) 755 return -Double.MIN_VALUE; 756 else 757 return Double.longBitsToDouble(Double.doubleToRawLongBits(d) + 758 ((d > 0.0d)?-1L:+1L)); 759 } 760 } 761 762 /** 763 * Returns the floating-point value adjacent to {@code f} in 764 * the direction of negative infinity. This method is 765 * semantically equivalent to {@code nextAfter(f, 766 * Float.NEGATIVE_INFINITY)}; however, a 767 * {@code nextDown} implementation may run faster than its 768 * equivalent {@code nextAfter} call. 769 * 770 * <p>Special Cases: 771 * <ul> 772 * <li> If the argument is NaN, the result is NaN. 773 * 774 * <li> If the argument is negative infinity, the result is 775 * negative infinity. 776 * 777 * <li> If the argument is zero, the result is 778 * {@code -Float.MIN_VALUE} 779 * 780 * </ul> 781 * 782 * @param f starting floating-point value 783 * @return The adjacent floating-point value closer to negative 784 * infinity. 785 * @author Joseph D. Darcy 786 */ 787 public static double nextDown(float f) { 788 if( isNaN(f) || f == Float.NEGATIVE_INFINITY) 789 return f; 790 else { 791 if (f == 0.0f) 792 return -Float.MIN_VALUE; 793 else 794 return Float.intBitsToFloat(Float.floatToRawIntBits(f) + 795 ((f > 0.0f)?-1:+1)); 796 } 797 } 798 799 /** 800 * Returns the first floating-point argument with the sign of the 801 * second floating-point argument. For this method, a NaN 802 * {@code sign} argument is always treated as if it were 803 * positive. 804 * 805 * @param magnitude the parameter providing the magnitude of the result 806 * @param sign the parameter providing the sign of the result 807 * @return a value with the magnitude of {@code magnitude} 808 * and the sign of {@code sign}. 809 * @author Joseph D. Darcy 810 * @since 1.5 811 * @deprecated Use StrictMath.copySign. 812 */ 813 @Deprecated 814 public static double copySign(double magnitude, double sign) { 815 return StrictMath.copySign(magnitude, sign); 816 } | 185 * @return a value with the magnitude of {@code magnitude} 186 * and the sign of {@code sign}. 187 * @author Joseph D. Darcy 188 * @deprecated Use Math.copySign. 189 */ 190 @Deprecated 191 public static float rawCopySign(float magnitude, float sign) { 192 return Math.copySign(magnitude, sign); 193 } 194 195 /* ***************************************************************** */ 196 197 /** 198 * Returns {@code true} if the argument is a finite 199 * floating-point value; returns {@code false} otherwise (for 200 * NaN and infinity arguments). 201 * 202 * @param d the {@code double} value to be tested 203 * @return {@code true} if the argument is a finite 204 * floating-point value, {@code false} otherwise. 205 * @deprecated Use Double.isFinite. 206 */ 207 @Deprecated 208 public static boolean isFinite(double d) { 209 return Double.isFinite(d); 210 } 211 212 /** 213 * Returns {@code true} if the argument is a finite 214 * floating-point value; returns {@code false} otherwise (for 215 * NaN and infinity arguments). 216 * 217 * @param f the {@code float} value to be tested 218 * @return {@code true} if the argument is a finite 219 * floating-point value, {@code false} otherwise. 220 * @deprecated Use Float.isFinite. 221 */ 222 @Deprecated 223 public static boolean isFinite(float f) { 224 return Float.isFinite(f); 225 } 226 227 /** 228 * Returns {@code true} if the specified number is infinitely 229 * large in magnitude, {@code false} otherwise. 230 * 231 * <p>Note that this method is equivalent to the {@link 232 * Double#isInfinite(double) Double.isInfinite} method; the 233 * functionality is included in this class for convenience. 234 * 235 * @param d the value to be tested. 236 * @return {@code true} if the value of the argument is positive 237 * infinity or negative infinity; {@code false} otherwise. 238 */ 239 public static boolean isInfinite(double d) { 240 return Double.isInfinite(d); 241 } 242 243 /** 244 * Returns {@code true} if the specified number is infinitely 733 * Double.NEGATIVE_INFINITY)}; however, a 734 * {@code nextDown} implementation may run faster than its 735 * equivalent {@code nextAfter} call. 736 * 737 * <p>Special Cases: 738 * <ul> 739 * <li> If the argument is NaN, the result is NaN. 740 * 741 * <li> If the argument is negative infinity, the result is 742 * negative infinity. 743 * 744 * <li> If the argument is zero, the result is 745 * {@code -Double.MIN_VALUE} 746 * 747 * </ul> 748 * 749 * @param d starting floating-point value 750 * @return The adjacent floating-point value closer to negative 751 * infinity. 752 * @author Joseph D. Darcy 753 * @deprecated Use Math.nextDown. 754 */ 755 @Deprecated 756 public static double nextDown(double d) { 757 return Math.nextDown(d); 758 } 759 760 /** 761 * Returns the floating-point value adjacent to {@code f} in 762 * the direction of negative infinity. This method is 763 * semantically equivalent to {@code nextAfter(f, 764 * Float.NEGATIVE_INFINITY)}; however, a 765 * {@code nextDown} implementation may run faster than its 766 * equivalent {@code nextAfter} call. 767 * 768 * <p>Special Cases: 769 * <ul> 770 * <li> If the argument is NaN, the result is NaN. 771 * 772 * <li> If the argument is negative infinity, the result is 773 * negative infinity. 774 * 775 * <li> If the argument is zero, the result is 776 * {@code -Float.MIN_VALUE} 777 * 778 * </ul> 779 * 780 * @param f starting floating-point value 781 * @return The adjacent floating-point value closer to negative 782 * infinity. 783 * @author Joseph D. Darcy 784 */ 785 @Deprecated 786 public static double nextDown(float f) { 787 return Math.nextDown(f); 788 } 789 790 /** 791 * Returns the first floating-point argument with the sign of the 792 * second floating-point argument. For this method, a NaN 793 * {@code sign} argument is always treated as if it were 794 * positive. 795 * 796 * @param magnitude the parameter providing the magnitude of the result 797 * @param sign the parameter providing the sign of the result 798 * @return a value with the magnitude of {@code magnitude} 799 * and the sign of {@code sign}. 800 * @author Joseph D. Darcy 801 * @since 1.5 802 * @deprecated Use StrictMath.copySign. 803 */ 804 @Deprecated 805 public static double copySign(double magnitude, double sign) { 806 return StrictMath.copySign(magnitude, sign); 807 } |