Code example for BigDecimal

Methods: toPlainString

0
    public static String formatToSignificant(double value,
            int significant)
         { 
            MathContext mathContext = new MathContext(significant,
               RoundingMode.DOWN);
            BigDecimal bigDecimal = new BigDecimal(value,
               mathContext);
            return bigDecimal.toPlainString();
         } 
 
    /** 
     * The "standard" method for rounding 
     * @param value The value to round 
     * @return String containing the rounded value 
     */ 
    private static String round(double value) {
        return formatToSignificant(value, SF);
    } 
 
    /** 
     * A string representation of a value, including the unit abbreviation