How to determine the max precision for double

后端 未结 4 1099
野性不改
野性不改 2020-12-06 16:54

I am trying to determine what the maximum precision for a double is. In the comments for the accepted answer in this link Retain precision with double in Java @PeterLawrey s

4条回答
  •  既然无缘
    2020-12-06 17:17

    The max precision of double of is the first value greater than 0. According Double's Javadoc, this number is represented by Double.MIN_VALUE. You can output it as follows:

    BigDecimal doubleMinVal = BigDecimal.valueOf(Double.MIN_VALUE);
    System.out.println(doubleMinVal.toPlainString());
    System.out.println(doubleMinVal.toString());
    

    See this IDEOne program for an example.

提交回复
热议问题