BookmarkSubscribeRSS Feed
0 Likes

1) If I run this under Windows:

data T;

  NB=0.5000000000000000000000000;  

  A=(0.5=NB); put A=;

  NB=0.500000000000000000000000;  

  A=(0.5=NB); put A=;

run;

 

SAS will not store the correct number in the first equality. The result is:

A=0

A=1

 

2) If I run the same code on a different platform, or if I add or remove zeros, the correct number is stored.

 

I think this should be recorded as a defect to be fixed.

 

More details on https://communities.sas.com/t5/Base-SAS-Programming/Expected-numeric-precision-behaviour-or-unexpect...

 

 

 

3 Comments
ChrisHemedinger
Community Manager

Numerical precision and how numbers are stored is governed by IEEE standards, as you probably know.  I think your main complaint is the difference you see across platforms, and not necessarily the imprecision in one vs the other?

 

This program shows a little bit more about how the numbers are stored:

 

data T;
  NB1=0.5000000000000000000000000;  
  put NB1:hex16.;
  A=(0.5=NB1); put A=;
  NB2=0.500000000000000000000000;  
  put NB2:hex16.;
  B=(0.5=NB2); put B=;
run;

Output on Windows:

3FDFFFFFFFFFFFFE
A=0
3FE0000000000000
B=1

On UNIX:

3FE0000000000000
A=1
3FE0000000000000
B=1
ChrisNZ
Tourmaline | Level 20

Thanks Chris, The information you mention is already discussed in the thread cited in my first post.

This is not a storage issue. It is a reading issue.

0.5 can be stored with full precision.

SAS under Windows (and no other platform, and WIN32 and W64 behave differently) reads some values erroneously.

ChrisNZ
Tourmaline | Level 20

Thank you @ChrisHemedinger for bringing Mike into the discussion the the forum thread!