Floating point 为什么在SAS中,科学记数法中的数字文字与显式写出的数字给出不同的数字?

Floating point 为什么在SAS中,科学记数法中的数字文字与显式写出的数字给出不同的数字?,floating-point,sas,scientific-notation,Floating Point,Sas,Scientific Notation,以下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代码:

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

看起来它实际上可能在计算
1*10*10…*10
并且一旦超出基本浮点类型的有效位数,错误就会悄悄地出现

但我不相信IEE754型浮点/双精度浮点/双精度浮点/双精度浮点/双精度浮点/双精度浮点/双精度浮点/双精度浮点/双精度浮点/双精度浮点/双精度浮点/双精度浮点/双精度浮点/双精度浮点/双精度浮点/双精度浮点/双精度浮点/双精度浮点/双精度浮点/双精度浮点/双

一种可能性是,您遇到的问题与以低于允许精度存储浮点数的能力有关(这可能会导致1e25计算出错)-有关解释,请参阅

更新1:

好的,根据你的评论,你没有限制长度。下面的代码给了你什么

t = 10;
u = 1e1;
put t u;
t = 100;
u = 1e2;
put t u;
t = 1000;
u = 1e3;
put t u;
: : :
t = 10000000000000000000000000;
u = 1e25;
put t u;

根据这一结果,我们可能可以推断出封面下发生了什么。

我没有限制数字的长度;它们是“长度8”(64位)的数字。我编辑了这个问题,给出了10的其他幂的值。