提交 4ba64fc9 编写于 作者: D darcy

7039369: Limit range of strictfp in FloatingDecimal

Summary: Additional reviews by sergey.kuksenko@oracle.com
Reviewed-by: alanb
上级 7047ec9f
...@@ -30,7 +30,7 @@ import sun.misc.DoubleConsts; ...@@ -30,7 +30,7 @@ import sun.misc.DoubleConsts;
import sun.misc.FloatConsts; import sun.misc.FloatConsts;
import java.util.regex.*; import java.util.regex.*;
public strictfp class FloatingDecimal{ public class FloatingDecimal{
boolean isExceptional; boolean isExceptional;
boolean isNegative; boolean isNegative;
int decExponent; int decExponent;
...@@ -239,8 +239,7 @@ public strictfp class FloatingDecimal{ ...@@ -239,8 +239,7 @@ public strictfp class FloatingDecimal{
* More difficult if subtracting and the argument * More difficult if subtracting and the argument
* is a normalized a power of 2, as the ULP changes at these points. * is a normalized a power of 2, as the ULP changes at these points.
*/ */
private static double private static double ulp( double dval, boolean subtracting ){
ulp( double dval, boolean subtracting ){
long lbits = Double.doubleToLongBits( dval ) & ~signMask; long lbits = Double.doubleToLongBits( dval ) & ~signMask;
int binexp = (int)(lbits >>> expShift); int binexp = (int)(lbits >>> expShift);
double ulpval; double ulpval;
...@@ -1251,8 +1250,7 @@ public strictfp class FloatingDecimal{ ...@@ -1251,8 +1250,7 @@ public strictfp class FloatingDecimal{
* for a single-precision float. * for a single-precision float.
*/ */
public double public strictfp double doubleValue(){
doubleValue(){
int kDigits = Math.min( nDigits, maxDecimalDigits+1 ); int kDigits = Math.min( nDigits, maxDecimalDigits+1 );
long lValue; long lValue;
double dValue; double dValue;
...@@ -1611,8 +1609,7 @@ public strictfp class FloatingDecimal{ ...@@ -1611,8 +1609,7 @@ public strictfp class FloatingDecimal{
* ( because of the preference to a zero low-order bit ). * ( because of the preference to a zero low-order bit ).
*/ */
public float public strictfp float floatValue(){
floatValue(){
int kDigits = Math.min( nDigits, singleMaxDecimalDigits+1 ); int kDigits = Math.min( nDigits, singleMaxDecimalDigits+1 );
int iValue; int iValue;
float fValue; float fValue;
......
...@@ -30,7 +30,7 @@ import sun.misc.DoubleConsts; ...@@ -30,7 +30,7 @@ import sun.misc.DoubleConsts;
import sun.misc.FloatConsts; import sun.misc.FloatConsts;
import java.util.regex.*; import java.util.regex.*;
public strictfp class FormattedFloatingDecimal{ public class FormattedFloatingDecimal{
boolean isExceptional; boolean isExceptional;
boolean isNegative; boolean isNegative;
int decExponent; // value set at construction, then immutable int decExponent; // value set at construction, then immutable
...@@ -247,8 +247,7 @@ public strictfp class FormattedFloatingDecimal{ ...@@ -247,8 +247,7 @@ public strictfp class FormattedFloatingDecimal{
* More difficult if subtracting and the argument * More difficult if subtracting and the argument
* is a normalized a power of 2, as the ULP changes at these points. * is a normalized a power of 2, as the ULP changes at these points.
*/ */
private static double private static double ulp( double dval, boolean subtracting ){
ulp( double dval, boolean subtracting ){
long lbits = Double.doubleToLongBits( dval ) & ~signMask; long lbits = Double.doubleToLongBits( dval ) & ~signMask;
int binexp = (int)(lbits >>> expShift); int binexp = (int)(lbits >>> expShift);
double ulpval; double ulpval;
...@@ -1157,8 +1156,7 @@ public strictfp class FormattedFloatingDecimal{ ...@@ -1157,8 +1156,7 @@ public strictfp class FormattedFloatingDecimal{
* for a single-precision float. * for a single-precision float.
*/ */
public double public strictfp double doubleValue(){
doubleValue(){
int kDigits = Math.min( nDigits, maxDecimalDigits+1 ); int kDigits = Math.min( nDigits, maxDecimalDigits+1 );
long lValue; long lValue;
double dValue; double dValue;
...@@ -1517,8 +1515,7 @@ public strictfp class FormattedFloatingDecimal{ ...@@ -1517,8 +1515,7 @@ public strictfp class FormattedFloatingDecimal{
* ( because of the preference to a zero low-order bit ). * ( because of the preference to a zero low-order bit ).
*/ */
public float public strictfp float floatValue(){
floatValue(){
int kDigits = Math.min( nDigits, singleMaxDecimalDigits+1 ); int kDigits = Math.min( nDigits, singleMaxDecimalDigits+1 );
int iValue; int iValue;
float fValue; float fValue;
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 4160406 4705734 4707389 4826774 4895911 4421494 7021568 * @bug 4160406 4705734 4707389 4826774 4895911 4421494 7021568 7039369
* @summary Test for Double.parseDouble method and acceptance regex * @summary Test for Double.parseDouble method and acceptance regex
*/ */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册