赞
踩
/** * Returns the string representation of the <code>double</code> argument. * <p> * The representation is exactly the one returned by the * <code>Double.toString</code> method of one argument. * * @param d a <code>double</code>. * @return a string representation of the <code>double</code> argument. * @see java.lang.Double#toString(double) */ public static String valueOf(double d) { return Double.toString(d); }
public static String toString(double d) { return new FloatingDecimal(d).toJavaFormatString(); }
* <li>If <i>m</i> is less than 10<sup>-3</sup> or greater than or * equal to 10<sup>7</sup>, then it is represented in so-called * "computerized scientific notation." Let <i>n</i> be the unique * integer such that 10<sup><i>n</i></sup> <= <i>m</i> < * 10<sup><i>n</i>+1</sup>; then let <i>a</i> be the * mathematically exact quotient of <i>m</i> and * 10<sup><i>n</i></sup> so that 1 <= <i>a</i> < 10. The * magnitude is then represented as the integer part of <i>a</i>, * as a single decimal digit, followed by '<code>.</code>' * (<code>'\u002E'</code>), followed by decimal digits * representing the fractional part of <i>a</i>, followed by the * letter '<code>E</code>' (<code>'\u0045'</code>), followed * by a representation of <i>n</i> as a decimal integer, as * produced by the method {@link Integer#toString(int)}.
DecimalFormat df = new DecimalFormat("###0.0#");//最多保留几位小数,就用几个#,最少位就用0来确定String s=df.format(d);
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。