Dear all,
I have a table with two columns as listed below:
Col_1 | Col_2 |
0.2 | -0.2 |
I then use an extract field and I create a calculated field "Col_3", which has the following expression
Col_1 + Col_2
The result of the addition should be equal to zero (0).
Instead, the following value is produced: 2.6841454E21
I have already tried to round the value, but nothing is happening.
Furthermore, when I use format and informat (which is something that I do not want, but after trying to troubleshoot the problem), a negative zero value is displayed.
Does anyone have any clue about this?
Thanks in advance,
Vasileios
This is roundoff error, and there's really no way to avoid this using computers. The problem is the 0.2 cannot be represented exactly as a string of 0s and 1s (which is how computers represent numbers).
If you really want a zero there, you can use the FUZZ() function.
if fuzz(col_1+col_2)=0 then col_3=0;
else col_3=col_1+col_2;
This is roundoff error, and there's really no way to avoid this using computers. The problem is the 0.2 cannot be represented exactly as a string of 0s and 1s (which is how computers represent numbers).
If you really want a zero there, you can use the FUZZ() function.
if fuzz(col_1+col_2)=0 then col_3=0;
else col_3=col_1+col_2;
I was watching a documentary the other day that was about the same reason for Warren Buffet not to trust computers in general 🙂
@novinosrin wrote:
I was watching a documentary the other day that was about the same reason for Warren Buffet not to trust computers in general 🙂
According to Mr. Buffet, is there a method that does not contain the possibility of error, and would be preferable?
@PaigeMiller wrote:
@novinosrin wrote:
I was watching a documentary the other day that was about the same reason for Warren Buffet not to trust computers in general 🙂
According to Mr. Buffet, is there a method that does not contain the possibility of error, and would be preferable?
I would add:
And can be done in an acceptable amount of time.
Pencil and paper with a properly trained person can do anything a computer can. It just takes time.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.