以下 SAS 代码:
data _null_;
format t u best32.;
t = 10000000000000000000000000;
u = 1e25;
put t u;
if t ne u then put 'diff';
run;
在我的 Windows 机器上打印出:
10000000000000000905969664 9999999999999998758486016
diff
虽然我知道只有前 15-16 位数字是可信的,但为什么它们给出不同的基础数字呢?SAS如何计算1e25?
编辑:我被要求提供 10 到 1e25 的其他幂的输出。以下程序:
%macro doit;
data _null_;
format t u best32.;
%let t=1;
%do i=1 %to 25;
%let t=&t.0;
t = &t;
u = 1e&i;
put t u;
%end;
run;
%mend;
%doit;
给出以下输出:
10 10
100 100
1000 1000
10000 10000
100000 100000
1000000 1000000
10000000 10000000
100000000 100000000
1000000000 1000000000
10000000000 10000000000
100000000000 100000000000
1000000000000 1000000000000
10000000000000 10000000000000
100000000000000 100000000000000
1000000000000000 1000000000000000
10000000000000000 10000000000000000
100000000000000000 100000000000000000
1000000000000000000 1000000000000000000
10000000000000000000 10000000000000000000
100000000000000000000 100000000000000000000
1000000000000000000000 1000000000000000000000
10000000000000000000000 10000000000000000000000
99999999999999991611392 99999999999999991611392
999999999999999983222784 999999999999999983222784
10000000000000000905969664 9999999999999998758486016