@LRogers wrote:
yes, when I do change to that format I see 823.99999999999
Hi @LRogers,
Please note that you were just lucky that one of the common numeric formats (such as w.d, BESTw. or Ew.) revealed the small difference (most likely a rounding error) between the stored number and 824 directly. There are several different numbers which these formats would display as if they were exactly 824, because these formats do some rounding. (Needless to say, this is no special feature of the number 824.)
Here are examples (assuming Windows or Unix operating systems):
data test;
input x hex16.;
cards;
4089BFFFFFFFFFFE
4089BFFFFFFFFFFF
4089C00000000000
4089C00000000001
4089C00000000002
;
Among the above five numbers (entered as their internal hexadecimal representations) only the third is equal to 824, but you would need either
a special format, ideally one that shows the internal representation (such as BINARY64. or HEX16.)
or the (non-default) system option setting DECIMALCONV=STDIEEE (in conjunction with a sufficient w.d format, e.g. 17.13)
in order to distinguish it from the other four values by just looking at a formatted value.
data _null_;
set test;
put x best32. +1 x 32.28 +1 x hex16.;
run;
Result (under Windows SAS 9.4 using the default DECIMALCONV=COMPATIBLE):
824 824.0000000000000000000000000000 4089BFFFFFFFFFFE
824 824.0000000000000000000000000000 4089BFFFFFFFFFFF
824 824.0000000000000000000000000000 4089C00000000000
824 824.0000000000000000000000000000 4089C00000000001
824 824.0000000000000000000000000000 4089C00000000002
Numbers like the four "deviating" cases above can easily result from calculations (as a consequence of rounding errors in floating-point arithmetic and numeric representation error):
data have;
x1=906.4/1.1;
x2=0.00824*100000;
run; /* Mathematically, both calculations result in 824, but ... */
proc print data=have noobs;
format x: hex16.;
run; /* ... not using the computer's floating-point arithmetic. */
Result (Windows SAS 9.4):
x1 x2
4089BFFFFFFFFFFF 4089C00000000001
So, it's always good to have the ROUND function at hand.
... View more