π如何在sas内计算?

All*_*owe 1 algorithm pi constants sas

只是好奇!但我发现SAS所持有的π值实际上是不正确的.

例如:

data _null_;
x= constant('pi') * 1000000000000000000000000000;
put x= 32.;
run;
Run Code Online (Sandbox Code Playgroud)

给出(3.)141592653589792961327005696的π值

然而 - π当然是(3.)1415926535897932384626433832795(http://www.joyofpi.com/pi.html) - 到31 dp.

是什么赋予了??!!

Gar*_*ler 6

PI在所有编程语言中保持为常量,达到设定精度.它没有计算.您的代码只暴露了PI在SAS中的准确程度.


cmj*_*hns 6

SAS将PI存储为14位小数.当您执行乘法步骤时,您看到的差异是浮点数学的假象.

data _null_;
    pi=constant("PI");
    put pi= 32.30;
run;
Run Code Online (Sandbox Code Playgroud)

/*On Log*/

pi=3.141592653589790000000000000000
Run Code Online (Sandbox Code Playgroud)