java中float的不精确行(最好用double)

public class Test {

	
	public static void main(String[] args) {
	

		String   sMoney   =   "350641.98 ";
		double   fMoney   =Double.parseDouble(sMoney);
		  System.out.println(fMoney);
		  
		  
		  String   sMoney2   =   "350641.98 ";
			Float  fMoney2   =Float.parseFloat(sMoney2);
			  System.out.println(fMoney2);
	
	}

}


结果是:
350641.98
350641.97

你可能感兴趣的:(java)