java有个java.text.DecimalFormat类,自己参考去

解决方案 »

  1.   

    public String round(float v) {
    BigDecimal b = new BigDecimal(Double.toString(v));
    BigDecimal one = new BigDecimal("1");
    String temp = b.divide(one, 2, BigDecimal.ROUND_HALF_UP).toString();
    int index = temp.indexOf(".");
    return temp = temp + "," + temp.substring(0,index);
    }
      

  2.   

    上面的有四舍五入~如果想不要四舍五入就用DecimalFormat
      

  3.   

    float f;
    DecimalFormat _df = new DecimalFormat("###,##0.00");
    String _strDf     =  _df.format(f);