有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!


共 (1) 个答案

  1. # 1 楼答案

    使用自定义^{}设置双精度值的格式:

    DecimalFormat fmt = new DecimalFormat("#0.000"); // leading zero and 3 fraction digits
    String result = fmt.format(11.123456789);
    System.out.println(result); // 11.123