Java Math.PI的价值有多精确?

时间:2012-01-12 15:45:26

标签: java math

我能获得PI的第N位数的最大N是多少?

6 个答案:

答案 0 :(得分:6)

public static final double PI = 3.141592653589793d

所以N = 16

这里的 API说http://docs.oracle.com/javase/6/docs/api/constant-values.html#java.lang.Math.PI

<小时/>

确实 Math.class的源代码

public static final double PI = 3.14159265358979323846;

N = 21


无论如何 - 这有点奇怪;)

答案 1 :(得分:5)

这是源代码中写的:

/**
 * The {@code double} value that is closer than any other to
 * <i>pi</i>, the ratio of the circumference of a circle to its
 * diameter.
 */
public static final double PI = 3.14159265358979323846;

答案 2 :(得分:2)

答案 3 :(得分:2)

来自javadocs

public static final double  PI  3.141592653589793d

它似乎被定义为15位小数。在this post中有关于这个主题的更多讨论。

答案 4 :(得分:0)

在源代码中:

/**
 * The {@code double} value that is closer than any other to
 * <i>pi</i>, the ratio of the circumference of a circle to its
 * diameter.
 */
public static final double PI = 3.14159265358979323846;

答案 5 :(得分:-1)

Pi的Java常量是近似值。 Pi的精确值在大多数计算中都是无关紧要的。

相关问题