科学记数法-指数E数字的处理

 

 

<fmt:formatNumber value="${Money }" pattern="#.##" minFractionDigits="2"></fmt:formatNumber>
 

 

public static void main(String[] args) {
		String ss = "9.86";
		Float ff =  Float.valueOf(ss);//float精度7
		ff =ff*100;
		System.out.println(ff);
		long result = ff.longValue();
		System.out.println(result);
		
		Double dd= Double.valueOf(ss);//double精度16
		BigDecimal bigD = new BigDecimal(dd);
		bigD = bigD.multiply(new BigDecimal(100)).divide(new BigDecimal(1), 1, BigDecimal.ROUND_HALF_UP);
		Long result2 = bigD.longValue();
		System.out.println(result2);
		
        MathContext mc = new MathContext(10); // 5 precision -- 5个有效数字
        BigDecimal bg = new BigDecimal("1.23456789E+10",mc);
        String s = bg.toPlainString();
        String str = "Plain string value of " + bg + " is " + s;
        System.out.println( str );
        
        float f = 12345678900000f;
        double d = 12345678900000d;
        System.out.println(new BigDecimal(f,mc).toPlainString());//12345679020000
        System.out.println(new BigDecimal(d,mc).toPlainString());//12345678900000
	}

 

参考链接:http://blog.csdn.net/ugg/article/details/8213666

你可能感兴趣的:(数字)