jdk/src/share/classes/java/util/Formatter.java
changeset 10598 efd29b4b3e67
parent 9689 53a4e9b16900
child 10608 7cfca36fc79b
equal deleted inserted replaced
10597:dac7cfce953a 10598:efd29b4b3e67
  3421                 // remove "0x"
  3421                 // remove "0x"
  3422                 return Double.toHexString(d).substring(2);
  3422                 return Double.toHexString(d).substring(2);
  3423             else {
  3423             else {
  3424                 assert(prec >= 1 && prec <= 12);
  3424                 assert(prec >= 1 && prec <= 12);
  3425 
  3425 
  3426                 int exponent  = FpUtils.getExponent(d);
  3426                 int exponent  = Math.getExponent(d);
  3427                 boolean subnormal
  3427                 boolean subnormal
  3428                     = (exponent == DoubleConsts.MIN_EXPONENT - 1);
  3428                     = (exponent == DoubleConsts.MIN_EXPONENT - 1);
  3429 
  3429 
  3430                 // If this is subnormal input so normalize (could be faster to
  3430                 // If this is subnormal input so normalize (could be faster to
  3431                 // do as integer operation).
  3431                 // do as integer operation).
  3432                 if (subnormal) {
  3432                 if (subnormal) {
  3433                     scaleUp = FpUtils.scalb(1.0, 54);
  3433                     scaleUp = Math.scalb(1.0, 54);
  3434                     d *= scaleUp;
  3434                     d *= scaleUp;
  3435                     // Calculate the exponent.  This is not just exponent + 54
  3435                     // Calculate the exponent.  This is not just exponent + 54
  3436                     // since the former is not the normalized exponent.
  3436                     // since the former is not the normalized exponent.
  3437                     exponent = FpUtils.getExponent(d);
  3437                     exponent = Math.getExponent(d);
  3438                     assert exponent >= DoubleConsts.MIN_EXPONENT &&
  3438                     assert exponent >= DoubleConsts.MIN_EXPONENT &&
  3439                         exponent <= DoubleConsts.MAX_EXPONENT: exponent;
  3439                         exponent <= DoubleConsts.MAX_EXPONENT: exponent;
  3440                 }
  3440                 }
  3441 
  3441 
  3442                 int precision = 1 + prec*4;
  3442                 int precision = 1 + prec*4;