mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8268224: Cleanup references to "strictfp" in core lib comments
Reviewed-by: jrose
This commit is contained in:
parent
516e60a7ee
commit
05df1727b5
2 changed files with 47 additions and 97 deletions
|
@ -1794,9 +1794,6 @@ public final class Math {
|
||||||
infiniteB && a == 0.0 ) {
|
infiniteB && a == 0.0 ) {
|
||||||
return Double.NaN;
|
return Double.NaN;
|
||||||
}
|
}
|
||||||
// Store product in a double field to cause an
|
|
||||||
// overflow even if non-strictfp evaluation is being
|
|
||||||
// used.
|
|
||||||
double product = a * b;
|
double product = a * b;
|
||||||
if (Double.isInfinite(product) && !infiniteA && !infiniteB) {
|
if (Double.isInfinite(product) && !infiniteA && !infiniteB) {
|
||||||
// Intermediate overflow; might cause a
|
// Intermediate overflow; might cause a
|
||||||
|
@ -2662,20 +2659,17 @@ public final class Math {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns {@code d} ×
|
* Returns {@code d} × 2<sup>{@code scaleFactor}</sup>
|
||||||
* 2<sup>{@code scaleFactor}</sup> rounded as if performed
|
* rounded as if performed by a single correctly rounded
|
||||||
* by a single correctly rounded floating-point multiply to a
|
* floating-point multiply. If the exponent of the result is
|
||||||
* member of the double value set. See the Java
|
* between {@link Double#MIN_EXPONENT} and {@link
|
||||||
* Language Specification for a discussion of floating-point
|
* Double#MAX_EXPONENT}, the answer is calculated exactly. If the
|
||||||
* value sets. If the exponent of the result is between {@link
|
* exponent of the result would be larger than {@code
|
||||||
* Double#MIN_EXPONENT} and {@link Double#MAX_EXPONENT}, the
|
* Double.MAX_EXPONENT}, an infinity is returned. Note that if
|
||||||
* answer is calculated exactly. If the exponent of the result
|
* the result is subnormal, precision may be lost; that is, when
|
||||||
* would be larger than {@code Double.MAX_EXPONENT}, an
|
* {@code scalb(x, n)} is subnormal, {@code scalb(scalb(x, n),
|
||||||
* infinity is returned. Note that if the result is subnormal,
|
* -n)} may not equal <i>x</i>. When the result is non-NaN, the
|
||||||
* precision may be lost; that is, when {@code scalb(x, n)}
|
* result has the same sign as {@code d}.
|
||||||
* is subnormal, {@code scalb(scalb(x, n), -n)} may not equal
|
|
||||||
* <i>x</i>. When the result is non-NaN, the result has the same
|
|
||||||
* sign as {@code d}.
|
|
||||||
*
|
*
|
||||||
* <p>Special cases:
|
* <p>Special cases:
|
||||||
* <ul>
|
* <ul>
|
||||||
|
@ -2693,9 +2687,7 @@ public final class Math {
|
||||||
*/
|
*/
|
||||||
public static double scalb(double d, int scaleFactor) {
|
public static double scalb(double d, int scaleFactor) {
|
||||||
/*
|
/*
|
||||||
* This method does not need to be declared strictfp to
|
* When scaling up, it does not matter what order the
|
||||||
* compute the same correct result on all platforms. When
|
|
||||||
* scaling up, it does not matter what order the
|
|
||||||
* multiply-store operations are done; the result will be
|
* multiply-store operations are done; the result will be
|
||||||
* finite or overflow regardless of the operation ordering.
|
* finite or overflow regardless of the operation ordering.
|
||||||
* However, to get the correct result when scaling down, a
|
* However, to get the correct result when scaling down, a
|
||||||
|
@ -2709,25 +2701,7 @@ public final class Math {
|
||||||
* by 2 ^ (scaleFactor % n) and then multiplying several
|
* by 2 ^ (scaleFactor % n) and then multiplying several
|
||||||
* times by 2^n as needed where n is the exponent of number
|
* times by 2^n as needed where n is the exponent of number
|
||||||
* that is a convenient power of two. In this way, at most one
|
* that is a convenient power of two. In this way, at most one
|
||||||
* real rounding error occurs. If the double value set is
|
* real rounding error occurs.
|
||||||
* being used exclusively, the rounding will occur on a
|
|
||||||
* multiply. If the double-extended-exponent value set is
|
|
||||||
* being used, the products will (perhaps) be exact but the
|
|
||||||
* stores to d are guaranteed to round to the double value
|
|
||||||
* set.
|
|
||||||
*
|
|
||||||
* It is _not_ a valid implementation to first multiply d by
|
|
||||||
* 2^MIN_EXPONENT and then by 2 ^ (scaleFactor %
|
|
||||||
* MIN_EXPONENT) since even in a strictfp program double
|
|
||||||
* rounding on underflow could occur; e.g. if the scaleFactor
|
|
||||||
* argument was (MIN_EXPONENT - n) and the exponent of d was a
|
|
||||||
* little less than -(MIN_EXPONENT - n), meaning the final
|
|
||||||
* result would be subnormal.
|
|
||||||
*
|
|
||||||
* Since exact reproducibility of this method can be achieved
|
|
||||||
* without any undue performance burden, there is no
|
|
||||||
* compelling reason to allow double rounding on underflow in
|
|
||||||
* scalb.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// magnitude of a power of two so large that scaling a finite
|
// magnitude of a power of two so large that scaling a finite
|
||||||
|
@ -2769,20 +2743,17 @@ public final class Math {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns {@code f} ×
|
* Returns {@code f} × 2<sup>{@code scaleFactor}</sup>
|
||||||
* 2<sup>{@code scaleFactor}</sup> rounded as if performed
|
* rounded as if performed by a single correctly rounded
|
||||||
* by a single correctly rounded floating-point multiply to a
|
* floating-point multiply. If the exponent of the result is
|
||||||
* member of the float value set. See the Java
|
* between {@link Float#MIN_EXPONENT} and {@link
|
||||||
* Language Specification for a discussion of floating-point
|
* Float#MAX_EXPONENT}, the answer is calculated exactly. If the
|
||||||
* value sets. If the exponent of the result is between {@link
|
* exponent of the result would be larger than {@code
|
||||||
* Float#MIN_EXPONENT} and {@link Float#MAX_EXPONENT}, the
|
* Float.MAX_EXPONENT}, an infinity is returned. Note that if the
|
||||||
* answer is calculated exactly. If the exponent of the result
|
* result is subnormal, precision may be lost; that is, when
|
||||||
* would be larger than {@code Float.MAX_EXPONENT}, an
|
* {@code scalb(x, n)} is subnormal, {@code scalb(scalb(x, n),
|
||||||
* infinity is returned. Note that if the result is subnormal,
|
* -n)} may not equal <i>x</i>. When the result is non-NaN, the
|
||||||
* precision may be lost; that is, when {@code scalb(x, n)}
|
* result has the same sign as {@code f}.
|
||||||
* is subnormal, {@code scalb(scalb(x, n), -n)} may not equal
|
|
||||||
* <i>x</i>. When the result is non-NaN, the result has the same
|
|
||||||
* sign as {@code f}.
|
|
||||||
*
|
*
|
||||||
* <p>Special cases:
|
* <p>Special cases:
|
||||||
* <ul>
|
* <ul>
|
||||||
|
@ -2814,9 +2785,7 @@ public final class Math {
|
||||||
* exponent range and + float -> double conversion is exact
|
* exponent range and + float -> double conversion is exact
|
||||||
* the multiplication below will be exact. Therefore, the
|
* the multiplication below will be exact. Therefore, the
|
||||||
* rounding that occurs when the double product is cast to
|
* rounding that occurs when the double product is cast to
|
||||||
* float will be the correctly rounded float result. Since
|
* float will be the correctly rounded float result.
|
||||||
* all operations other than the final multiply will be exact,
|
|
||||||
* it is not necessary to declare this method strictfp.
|
|
||||||
*/
|
*/
|
||||||
return (float)((double)f*powerOfTwoD(scaleFactor));
|
return (float)((double)f*powerOfTwoD(scaleFactor));
|
||||||
}
|
}
|
||||||
|
|
|
@ -469,19 +469,6 @@ public final class StrictMath {
|
||||||
* away any fractional portion of a since ulp(twoToThe52) ==
|
* away any fractional portion of a since ulp(twoToThe52) ==
|
||||||
* 1.0; subtracting out twoToThe52 from this sum will then be
|
* 1.0; subtracting out twoToThe52 from this sum will then be
|
||||||
* exact and leave the rounded integer portion of a.
|
* exact and leave the rounded integer portion of a.
|
||||||
*
|
|
||||||
* This method does *not* need to be declared strictfp to get
|
|
||||||
* fully reproducible results. Whether or not a method is
|
|
||||||
* declared strictfp can only make a difference in the
|
|
||||||
* returned result if some operation would overflow or
|
|
||||||
* underflow with strictfp semantics. The operation
|
|
||||||
* (twoToThe52 + a ) cannot overflow since large values of a
|
|
||||||
* are screened out; the add cannot underflow since twoToThe52
|
|
||||||
* is too large. The subtraction ((twoToThe52 + a ) -
|
|
||||||
* twoToThe52) will be exact as discussed above and thus
|
|
||||||
* 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 twoToThe52 = (double)(1L << 52); // 2^52
|
||||||
double sign = Math.copySign(1.0, a); // preserve sign info
|
double sign = Math.copySign(1.0, a); // preserve sign info
|
||||||
|
@ -2060,20 +2047,17 @@ public final class StrictMath {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns {@code d} ×
|
* Returns {@code d} × 2<sup>{@code scaleFactor}</sup>
|
||||||
* 2<sup>{@code scaleFactor}</sup> rounded as if performed
|
* rounded as if performed by a single correctly rounded
|
||||||
* by a single correctly rounded floating-point multiply to a
|
* floating-point multiply. If the exponent of the result is
|
||||||
* member of the double value set. See the Java
|
* between {@link Double#MIN_EXPONENT} and {@link
|
||||||
* Language Specification for a discussion of floating-point
|
* Double#MAX_EXPONENT}, the answer is calculated exactly. If the
|
||||||
* value sets. If the exponent of the result is between {@link
|
* exponent of the result would be larger than {@code
|
||||||
* Double#MIN_EXPONENT} and {@link Double#MAX_EXPONENT}, the
|
* Double.MAX_EXPONENT}, an infinity is returned. Note that if
|
||||||
* answer is calculated exactly. If the exponent of the result
|
* the result is subnormal, precision may be lost; that is, when
|
||||||
* would be larger than {@code Double.MAX_EXPONENT}, an
|
* {@code scalb(x, n)} is subnormal, {@code scalb(scalb(x, n),
|
||||||
* infinity is returned. Note that if the result is subnormal,
|
* -n)} may not equal <i>x</i>. When the result is non-NaN, the
|
||||||
* precision may be lost; that is, when {@code scalb(x, n)}
|
* result has the same sign as {@code d}.
|
||||||
* is subnormal, {@code scalb(scalb(x, n), -n)} may not equal
|
|
||||||
* <i>x</i>. When the result is non-NaN, the result has the same
|
|
||||||
* sign as {@code d}.
|
|
||||||
*
|
*
|
||||||
* <p>Special cases:
|
* <p>Special cases:
|
||||||
* <ul>
|
* <ul>
|
||||||
|
@ -2094,20 +2078,17 @@ public final class StrictMath {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns {@code f} ×
|
* Returns {@code f} × 2<sup>{@code scaleFactor}</sup>
|
||||||
* 2<sup>{@code scaleFactor}</sup> rounded as if performed
|
* rounded as if performed by a single correctly rounded
|
||||||
* by a single correctly rounded floating-point multiply to a
|
* floating-point multiply. If the exponent of the result is
|
||||||
* member of the float value set. See the Java
|
* between {@link Float#MIN_EXPONENT} and {@link
|
||||||
* Language Specification for a discussion of floating-point
|
* Float#MAX_EXPONENT}, the answer is calculated exactly. If the
|
||||||
* value sets. If the exponent of the result is between {@link
|
* exponent of the result would be larger than {@code
|
||||||
* Float#MIN_EXPONENT} and {@link Float#MAX_EXPONENT}, the
|
* Float.MAX_EXPONENT}, an infinity is returned. Note that if the
|
||||||
* answer is calculated exactly. If the exponent of the result
|
* result is subnormal, precision may be lost; that is, when
|
||||||
* would be larger than {@code Float.MAX_EXPONENT}, an
|
* {@code scalb(x, n)} is subnormal, {@code scalb(scalb(x, n),
|
||||||
* infinity is returned. Note that if the result is subnormal,
|
* -n)} may not equal <i>x</i>. When the result is non-NaN, the
|
||||||
* precision may be lost; that is, when {@code scalb(x, n)}
|
* result has the same sign as {@code f}.
|
||||||
* is subnormal, {@code scalb(scalb(x, n), -n)} may not equal
|
|
||||||
* <i>x</i>. When the result is non-NaN, the result has the same
|
|
||||||
* sign as {@code f}.
|
|
||||||
*
|
*
|
||||||
* <p>Special cases:
|
* <p>Special cases:
|
||||||
* <ul>
|
* <ul>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue