8164524: Correct inconsistencies in floating-point abs spec

Reviewed-by: martin, bpb
This commit is contained in:
Joe Darcy 2016-08-22 17:22:09 -07:00
parent 9517153e77
commit d6dfc0bef3
2 changed files with 28 additions and 8 deletions
jdk/src/java.base/share/classes/java/lang

@ -1370,8 +1370,13 @@ public final class Math {
* result is positive zero.
* <li>If the argument is infinite, the result is positive infinity.
* <li>If the argument is NaN, the result is NaN.</ul>
* In other words, the result is the same as the value of the expression:
* <p>{@code Float.intBitsToFloat(0x7fffffff & Float.floatToIntBits(a))}
*
* @apiNote As implied by the above, one valid implementation of
* this method is given by the expression below which computes a
* {@code float} with the same exponent and significand as the
* argument but with a guaranteed zero sign bit indicating a
* positive value:<br>
* {@code Float.intBitsToFloat(0x7fffffff & Float.floatToRawIntBits(a))}
*
* @param a the argument whose absolute value is to be determined
* @return the absolute value of the argument.
@ -1389,8 +1394,13 @@ public final class Math {
* is positive zero.
* <li>If the argument is infinite, the result is positive infinity.
* <li>If the argument is NaN, the result is NaN.</ul>
* In other words, the result is the same as the value of the expression:
* <p>{@code Double.longBitsToDouble((Double.doubleToLongBits(a)<<1)>>>1)}
*
* @apiNote As implied by the above, one valid implementation of
* this method is given by the expression below which computes a
* {@code double} with the same exponent and significand as the
* argument but with a guaranteed zero sign bit indicating a
* positive value:<br>
* {@code Double.longBitsToDouble((Double.doubleToRawLongBits(a)<<1)>>>1)}
*
* @param a the argument whose absolute value is to be determined
* @return the absolute value of the argument.

@ -1070,8 +1070,13 @@ public final class StrictMath {
* result is positive zero.
* <li>If the argument is infinite, the result is positive infinity.
* <li>If the argument is NaN, the result is NaN.</ul>
* In other words, the result is the same as the value of the expression:
* <p>{@code Float.intBitsToFloat(0x7fffffff & Float.floatToIntBits(a))}
*
* @apiNote As implied by the above, one valid implementation of
* this method is given by the expression below which computes a
* {@code float} with the same exponent and significand as the
* argument but with a guaranteed zero sign bit indicating a
* positive value: <br>
* {@code Float.intBitsToFloat(0x7fffffff & Float.floatToRawIntBits(a))}
*
* @param a the argument whose absolute value is to be determined
* @return the absolute value of the argument.
@ -1089,8 +1094,13 @@ public final class StrictMath {
* is positive zero.
* <li>If the argument is infinite, the result is positive infinity.
* <li>If the argument is NaN, the result is NaN.</ul>
* In other words, the result is the same as the value of the expression:
* <p>{@code Double.longBitsToDouble((Double.doubleToLongBits(a)<<1)>>>1)}
*
* @apiNote As implied by the above, one valid implementation of
* this method is given by the expression below which computes a
* {@code double} with the same exponent and significand as the
* argument but with a guaranteed zero sign bit indicating a
* positive value: <br>
* {@code Double.longBitsToDouble((Double.doubleToRawLongBits(a)<<1)>>>1)}
*
* @param a the argument whose absolute value is to be determined
* @return the absolute value of the argument.