src/share/classes/sun/misc/FormattedFloatingDecimal.java

Print this page

        

*** 1015,1026 **** --- 1015,1034 ---- if (exp - 1 < -4 || exp - 1 >= precision) { form = Form.SCIENTIFIC; precision--; } else { form = Form.DECIMAL_FLOAT; + if (digits.length == 1 && digits[0] == '0' + && precision == 1) { + // When the number is zero and precision is 1, set the + // precision to 0 so that a decimal point and digits + // are not added by code later in this method. + precision--; + } else { precision = precision - exp; } + } break; default: assert false; } decExponentRounded = exp;