Java 两数相除保留n位小数
public static void main(String[] args) throws Exception { int a = 15; int b = 3; double result = a*1.0/b; DecimalFormat f = new DecimalFormat("#0.0"); String d = f.format(result); System.out.println(d); }
    有些事情,没经历过不知道原理,没失败过不明白奥妙,没痛苦过不了解真谛。临渊羡鱼,不如退而结网!
                    
                
                
            
        
浙公网安备 33010602011771号