Withdraw: Review: 4396272 - Parsing doubles fails to follow IEEE for largest decimal that should yield 0 (original) (raw)

Dmitry Nadezhin dmitry.nadezhin at gmail.com
Fri Feb 22 20:29:49 UTC 2013


Brian,

I removed unused methods and fields from FormattedFloatingDecimal. JDK build passes. The result of "hg diff" is attached.

-Dima

On Fri, Feb 22, 2013 at 9:49 PM, Brian Burkhalter <brian.burkhalter at oracle.com> wrote: > Dima, >> If the methods are definitely unused that would be correct. I suppose if a > clean build of the JDK does not complain then it is acceptable and correct. >> Thanks, >> Brian >> On Feb 22, 2013, at 9:41 AM, Dmitry Nadezhin wrote: >> So I think that the required change in FormattedFloatingDecimal is to > delete methods > doubleValue(), floatValue() and other unused methods and fields. Am I right > ? >>-------------- next part -------------- diff -r bb97c93e4fd7 src/share/classes/sun/misc/FormattedFloatingDecimal.java --- a/src/share/classes/sun/misc/FormattedFloatingDecimal.java Thu Feb 21 11:13:23 2013 -0800 +++ b/src/share/classes/sun/misc/FormattedFloatingDecimal.java Sat Feb 23 00:00:12 2013 +0400 @@ -25,10 +25,6 @@ package sun.misc; -import sun.misc.DoubleConsts; -import sun.misc.FloatConsts; -import java.util.regex.*;

public class FormattedFloatingDecimal{ boolean isExceptional; boolean isNegative; @@ -38,9 +34,6 @@ int nDigits; int bigIntExp; int bigIntNBits; - boolean mustSetRoundDir = false; - boolean fromHex = false; - int roundDir = 0; // set by doubleValue int precision; // number of digits to the right of decimal public enum Form { SCIENTIFIC, COMPATIBLE, DECIMAL_FLOAT, GENERAL }; @@ -72,10 +65,6 @@ static final long expOne = ((long)expBias)<<expShift; // exponent of 1.0 static final int maxSmallBinExp = 62; static final int minSmallBinExp = -( 63 / 3 ); - static final int maxDecimalDigits = 15; - static final int maxDecimalExponent = 308; - static final int minDecimalExponent = -324; - static final int bigDecimalExponent = 324; // i.e. abs(minDecimalExponent) static final long highbyte = 0xff00000000000000L; static final long highbit = 0x8000000000000000L; @@ -87,12 +76,6 @@ static final int singleExpShift = 23; static final int singleFractHOB = 1<<singleExpShift; static final int singleExpBias = 127; - static final int singleMaxDecimalDigits = 7; - static final int singleMaxDecimalExponent = 38; - static final int singleMinDecimalExponent = -45;

 /*
  * count number of bits from high-order 1 bit to low-order 1 bit,

@@ -241,56 +224,6 @@ } /* - * Compute a number that is the ULP of the given value, - * for purposes of addition/subtraction. Generally easy. - * More difficult if subtracting and the argument - * is a normalized a power of 2, as the ULP changes at these points. - */ - private static double ulp( double dval, boolean subtracting ){ - long lbits = Double.doubleToLongBits( dval ) & ~signMask; - int binexp = (int)(lbits >>> expShift); - double ulpval; - if ( subtracting && ( binexp >= expShift ) && ((lbits&fractMask) == 0L) ){ - // for subtraction from normalized, powers of 2, - // use next-smaller exponent - binexp -= 1; - } - if ( binexp > expShift ){ - ulpval = Double.longBitsToDouble( ((long)(binexp-expShift))<<expShift ); - } else if ( binexp == 0 ){ - ulpval = Double.MIN_VALUE; - } else { - ulpval = Double.longBitsToDouble( 1L<<(binexp-1) ); - } - if ( subtracting ) ulpval = - ulpval;



More information about the core-libs-dev mailing list