Previous PageNext Page

Let's add up 1/10 ten times
data _null_;
x=0;
do i=1 to 10;
x+0.1;
put '(hex)' x=hex16. @30 '(formatted dec)' x=;
end;
one=1;
if x=1 then put 'x is equal to 1';
else put 'what happened?'/
'(hex)' one=hex16.;
run;
What is 10·.1?
(hex)X=3FB999999999999A (formatted dec)X=0.1
(hex)X=3FC999999999999A (formatted dec)X=0.2
(hex)X=3FD3333333333334 (formatted dec)X=0.3
(hex)X=3FD999999999999A (formatted dec)X=0.4
(hex)X=3FE0000000000000 (formatted dec)X=0.5
(hex)X=3FE3333333333333 (formatted dec)X=0.6
(hex)X=3FE6666666666666 (formatted dec)X=0.7
(hex)X=3FE9999999999999 (formatted dec)X=0.8
(hex)X=3FECCCCCCCCCCCCC (formatted dec)X=0.9
(hex)X=3FEFFFFFFFFFFFFF (formatted dec)X=1
what happened?
(hex)ONE=3FF0000000000000

Previous PageTable Of ContentsNext Page