Tagged with " Computer numbering format"

The Winner Of July Programming Challenge Is Jiangtang Hu

Aug 15, 2011 by     No Comments    Posted under: Code, Monthly Contest, New Technologies, Tips & Techniques

Our last programming challenge is Infinitesimal in the SAS universe of discourse. The following code and the like provide a predicate to approach that “infinitesimal”:


data _null_; x=1;
do until (0=x/2);x=x/2;c+1;end;
put c= x= binary64.;
run;

The put statement writes in the log the output:

c=1074 x=0000000000000000000000000000000000000000000000000000000000000001

In another word, the sas infinitesimal is 2^{-1074}.

Some programmers provided the solution by using sas contant “SMALL”. On the surface level and surprisingly, it is not the smallest number in sas universe:

data _null_;x=constant('SMALL'); y=x/2; z=x>y; put x= binary64. y= binary64. z=;run;

Log:

x=0000000000010000000000000000000000000000000000000000000000000000
y=0000000000001000000000000000000000000000000000000000000000000000 z=1

The rationale behind the definition of “SMALL”, from my understanding, is “SMALL” is the smallest number that the implicit bit algorithm (see IEEE 754) to encode floating point numbers is applicable.

More code to play:

data _null_; x=log2(constant('SMALL')); put x=;run;

Log:

x=-1022

Programming Challenge: Infinitesimal in the SAS universe of discourse

Jul 8, 2011 by     1 Comment     Posted under: Code, Monthly Contest, New Technologies, Tips & Techniques

First of all, thank Jonathan Lee, Jiangtang Hu, Jacques Thibault, Neha Mohan and Na Li for their feedback on the question about the largest 3-byte integer in sas dataset in our Code Jeet Kune Do email list. Code Jeet Kune Do is expanded from our internal Q&A mail list for technique and knowledge sharing. If you are interested to subscribe, please shoot me a message at jian.dai@clinovo.com to add your email there.

Second, the term “infinitesimal” in the title is a bit misleading. Here is how the game is specified: Please use a program to find the minimal positive number that SAS can represent and send your code to me by August 1, 2011. The one who gets it right first wins :)

Hint: The following code is a brutal-force approach to pin down the maximal integer that SAS can represent.

data _null_;do until(x=x+1);x+1;end;put x= binary64.;run;

Don’t run it as I estimate it takes about 456 days to exit the loop on my laptop (unless you can access to a super super fast machine) :)

Reference:
Jacques and I discovered an excellent paper on this subject that you can use: Numeric Length: Concepts and Consequences. This topic is along the line of the post Play Dataset Like a CS Pro: Binary Tree as it touches some fundamental issues in the field of computation.

Check out the BioNews, a very handy daily recap of the latest industry news!