src/share/classes/java/lang/StrictMath.java

Print this page

        

*** 23,33 **** * questions. */ package java.lang; import java.util.Random; - import sun.misc.FpUtils; import sun.misc.DoubleConsts; /** * The class {@code StrictMath} contains methods for performing basic * numeric operations such as the elementary exponential, logarithm, --- 23,32 ----
*** 426,436 **** * cannot overflow or meaningfully underflow. Finally, the * last multiply in the return statement is by plus or minus * 1.0, which is exact too. */ double twoToThe52 = (double)(1L << 52); // 2^52 ! double sign = FpUtils.rawCopySign(1.0, a); // preserve sign info a = Math.abs(a); if (a < twoToThe52) { // E_min <= ilogb(a) <= 51 a = ((twoToThe52 + a ) - twoToThe52); } --- 425,435 ---- * cannot overflow or meaningfully underflow. Finally, the * last multiply in the return statement is by plus or minus * 1.0, which is exact too. */ double twoToThe52 = (double)(1L << 52); // 2^52 ! double sign = Math.copySign(1.0, a); // preserve sign info a = Math.abs(a); if (a < twoToThe52) { // E_min <= ilogb(a) <= 51 a = ((twoToThe52 + a ) - twoToThe52); }
*** 953,963 **** * @return the size of an ulp of the argument * @author Joseph D. Darcy * @since 1.5 */ public static double ulp(double d) { ! return sun.misc.FpUtils.ulp(d); } /** * Returns the size of an ulp of the argument. An ulp, unit in * the last place, of a {@code float} value is the positive --- 952,962 ---- * @return the size of an ulp of the argument * @author Joseph D. Darcy * @since 1.5 */ public static double ulp(double d) { ! return Math.ulp(d); } /** * Returns the size of an ulp of the argument. An ulp, unit in * the last place, of a {@code float} value is the positive
*** 980,990 **** * @return the size of an ulp of the argument * @author Joseph D. Darcy * @since 1.5 */ public static float ulp(float f) { ! return sun.misc.FpUtils.ulp(f); } /** * Returns the signum function of the argument; zero if the argument * is zero, 1.0 if the argument is greater than zero, -1.0 if the --- 979,989 ---- * @return the size of an ulp of the argument * @author Joseph D. Darcy * @since 1.5 */ public static float ulp(float f) { ! return Math.ulp(f); } /** * Returns the signum function of the argument; zero if the argument * is zero, 1.0 if the argument is greater than zero, -1.0 if the
*** 1001,1011 **** * @return the signum function of the argument * @author Joseph D. Darcy * @since 1.5 */ public static double signum(double d) { ! return sun.misc.FpUtils.signum(d); } /** * Returns the signum function of the argument; zero if the argument * is zero, 1.0f if the argument is greater than zero, -1.0f if the --- 1000,1010 ---- * @return the signum function of the argument * @author Joseph D. Darcy * @since 1.5 */ public static double signum(double d) { ! return Math.signum(d); } /** * Returns the signum function of the argument; zero if the argument * is zero, 1.0f if the argument is greater than zero, -1.0f if the
*** 1022,1032 **** * @return the signum function of the argument * @author Joseph D. Darcy * @since 1.5 */ public static float signum(float f) { ! return sun.misc.FpUtils.signum(f); } /** * Returns the hyperbolic sine of a {@code double} value. * The hyperbolic sine of <i>x</i> is defined to be --- 1021,1031 ---- * @return the signum function of the argument * @author Joseph D. Darcy * @since 1.5 */ public static float signum(float f) { ! return Math.signum(f); } /** * Returns the hyperbolic sine of a {@code double} value. * The hyperbolic sine of <i>x</i> is defined to be
*** 1200,1210 **** * @return a value with the magnitude of {@code magnitude} * and the sign of {@code sign}. * @since 1.6 */ public static double copySign(double magnitude, double sign) { ! return sun.misc.FpUtils.copySign(magnitude, sign); } /** * Returns the first floating-point argument with the sign of the * second floating-point argument. For this method, a NaN --- 1199,1209 ---- * @return a value with the magnitude of {@code magnitude} * and the sign of {@code sign}. * @since 1.6 */ public static double copySign(double magnitude, double sign) { ! return Math.copySign(magnitude, (Double.isNaN(sign)?1.0d:sign)); } /** * Returns the first floating-point argument with the sign of the * second floating-point argument. For this method, a NaN
*** 1216,1226 **** * @return a value with the magnitude of {@code magnitude} * and the sign of {@code sign}. * @since 1.6 */ public static float copySign(float magnitude, float sign) { ! return sun.misc.FpUtils.copySign(magnitude, sign); } /** * Returns the unbiased exponent used in the representation of a * {@code float}. Special cases: * --- 1215,1225 ---- * @return a value with the magnitude of {@code magnitude} * and the sign of {@code sign}. * @since 1.6 */ public static float copySign(float magnitude, float sign) { ! return Math.copySign(magnitude, (Float.isNaN(sign)?1.0f:sign)); } /** * Returns the unbiased exponent used in the representation of a * {@code float}. Special cases: *
*** 1232,1242 **** * </ul> * @param f a {@code float} value * @since 1.6 */ public static int getExponent(float f) { ! return sun.misc.FpUtils.getExponent(f); } /** * Returns the unbiased exponent used in the representation of a * {@code double}. Special cases: --- 1231,1241 ---- * </ul> * @param f a {@code float} value * @since 1.6 */ public static int getExponent(float f) { ! return Math.getExponent(f); } /** * Returns the unbiased exponent used in the representation of a * {@code double}. Special cases:
*** 1249,1259 **** * </ul> * @param d a {@code double} value * @since 1.6 */ public static int getExponent(double d) { ! return sun.misc.FpUtils.getExponent(d); } /** * Returns the floating-point number adjacent to the first * argument in the direction of the second argument. If both --- 1248,1258 ---- * </ul> * @param d a {@code double} value * @since 1.6 */ public static int getExponent(double d) { ! return Math.getExponent(d); } /** * Returns the floating-point number adjacent to the first * argument in the direction of the second argument. If both
*** 1292,1302 **** * @return The floating-point number adjacent to {@code start} in the * direction of {@code direction}. * @since 1.6 */ public static double nextAfter(double start, double direction) { ! return sun.misc.FpUtils.nextAfter(start, direction); } /** * Returns the floating-point number adjacent to the first * argument in the direction of the second argument. If both --- 1291,1301 ---- * @return The floating-point number adjacent to {@code start} in the * direction of {@code direction}. * @since 1.6 */ public static double nextAfter(double start, double direction) { ! return Math.nextAfter(start, direction); } /** * Returns the floating-point number adjacent to the first * argument in the direction of the second argument. If both
*** 1334,1344 **** * @return The floating-point number adjacent to {@code start} in the * direction of {@code direction}. * @since 1.6 */ public static float nextAfter(float start, double direction) { ! return sun.misc.FpUtils.nextAfter(start, direction); } /** * Returns the floating-point value adjacent to {@code d} in * the direction of positive infinity. This method is --- 1333,1343 ---- * @return The floating-point number adjacent to {@code start} in the * direction of {@code direction}. * @since 1.6 */ public static float nextAfter(float start, double direction) { ! return Math.nextAfter(start, direction); } /** * Returns the floating-point value adjacent to {@code d} in * the direction of positive infinity. This method is
*** 1363,1373 **** * @return The adjacent floating-point value closer to positive * infinity. * @since 1.6 */ public static double nextUp(double d) { ! return sun.misc.FpUtils.nextUp(d); } /** * Returns the floating-point value adjacent to {@code f} in * the direction of positive infinity. This method is --- 1362,1372 ---- * @return The adjacent floating-point value closer to positive * infinity. * @since 1.6 */ public static double nextUp(double d) { ! return Math.nextUp(d); } /** * Returns the floating-point value adjacent to {@code f} in * the direction of positive infinity. This method is
*** 1392,1405 **** * @return The adjacent floating-point value closer to positive * infinity. * @since 1.6 */ public static float nextUp(float f) { ! return sun.misc.FpUtils.nextUp(f); } - /** * Return {@code d} &times; * 2<sup>{@code scaleFactor}</sup> rounded as if performed * by a single correctly rounded floating-point multiply to a * member of the double value set. See the Java --- 1391,1403 ---- * @return The adjacent floating-point value closer to positive * infinity. * @since 1.6 */ public static float nextUp(float f) { ! return Math.nextUp(f); } /** * Return {@code d} &times; * 2<sup>{@code scaleFactor}</sup> rounded as if performed * by a single correctly rounded floating-point multiply to a * member of the double value set. See the Java
*** 1427,1437 **** * @param scaleFactor power of 2 used to scale {@code d} * @return {@code d} &times; 2<sup>{@code scaleFactor}</sup> * @since 1.6 */ public static double scalb(double d, int scaleFactor) { ! return sun.misc.FpUtils.scalb(d, scaleFactor); } /** * Return {@code f} &times; * 2<sup>{@code scaleFactor}</sup> rounded as if performed --- 1425,1435 ---- * @param scaleFactor power of 2 used to scale {@code d} * @return {@code d} &times; 2<sup>{@code scaleFactor}</sup> * @since 1.6 */ public static double scalb(double d, int scaleFactor) { ! return Math.scalb(d, scaleFactor); } /** * Return {@code f} &times; * 2<sup>{@code scaleFactor}</sup> rounded as if performed
*** 1461,1468 **** * @param scaleFactor power of 2 used to scale {@code f} * @return {@code f} &times; 2<sup>{@code scaleFactor}</sup> * @since 1.6 */ public static float scalb(float f, int scaleFactor) { ! return sun.misc.FpUtils.scalb(f, scaleFactor); } } --- 1459,1466 ---- * @param scaleFactor power of 2 used to scale {@code f} * @return {@code f} &times; 2<sup>{@code scaleFactor}</sup> * @since 1.6 */ public static float scalb(float f, int scaleFactor) { ! return Math.scalb(f, scaleFactor); } }