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);
    }

 

posted @ 2025-09-24 15:16  都是城市惹的祸  阅读(2)  评论(0)    收藏  举报