**When is zero not zero?**

Here is another one. What is: -16 -**.**1 +16 +**.**1?

data _null_;

/* Is this zero? */

x= -16-0.1+16+0.1;

put x= hex16. x= '<= expression 1'/;

/* By breaking apart the expression, you can see */

/* where representation error is introduced and */

/* where loss of significance occurs. */

x= -16;

put x= hex16. x=;

x= x-0.1;

put x= hex16. x= '<= representation error';

x= x+16;

put x= hex16. x= '<= loss of significance';

x= x+0.1;

put x= hex16. x= /;

run;

The output is as follows:

X=BCD9800000000000 X=-1.41553E-15 <= expression 1

X=C030000000000000 X=-16

X=C03019999999999A X=-16.1 <= representation error

X=BFB9999999999A00 X=-0.1 <= loss of significance

X=BCD9800000000000 X=-1.41553E-15

If you change the order of the operands, the expression will evaluate correctly.

x= 16-16+0.1-0.1;

put x= hex16. x= '<= expression 2';

The output is as follows:

X=0000000000000000 X=0 <= expression 2