From: <ag...@us...> - 2008-09-15 06:28:52
|
Revision: 764 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=764&view=rev Author: agraef Date: 2008-09-15 06:29:02 +0000 (Mon, 15 Sep 2008) Log Message: ----------- Move inf and nan definitions back to primitives.pure, but make sure that they come after the definition of the arithmetic operators, so that the double arithmetic gets expanded at compile time. Modified Paths: -------------- pure/trunk/interpreter.cc pure/trunk/lib/primitives.pure Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-09-15 05:45:18 UTC (rev 763) +++ pure/trunk/interpreter.cc 2008-09-15 06:29:02 UTC (rev 764) @@ -330,7 +330,6 @@ const string& host, const list<string>& argv) { - static const double inf = 1.0e307 * 1.0e307, nan = inf-inf; // command line arguments, system and version information pure_expr *args = pure_const(symtab.nil_sym().f); for (list<string>::const_reverse_iterator it = argv.rbegin(); @@ -347,8 +346,6 @@ #ifdef HAVE_GSL defn("gsl_version", pure_cstring_dup(gsl_version)); #endif - const_defn("inf", pure_double(inf)); - const_defn("nan", pure_double(nan)); } // Errors and warnings. Modified: pure/trunk/lib/primitives.pure =================================================================== --- pure/trunk/lib/primitives.pure 2008-09-15 05:45:18 UTC (rev 763) +++ pure/trunk/lib/primitives.pure 2008-09-15 06:29:02 UTC (rev 764) @@ -63,11 +63,6 @@ tuplep (x,xs) = 1; tuplep _ = 0 otherwise; -/* Predicates to check for IEEE floating point infinities and NaNs. */ - -infp x = case x of x::double = x==inf || x==-inf; _ = 0 end; -nanp x = case x of x::double = not (x==x); _ = 0 end; - /* Compute a 32 bit hash code of a Pure expression. */ extern int hash(expr*); @@ -388,6 +383,16 @@ x::pointer==y::pointer = bigint x == bigint y; x::pointer!=y::pointer = bigint x != bigint y; +/* IEEE floating point infinities and NaNs. Place these after the definitions + of the built-in operators so that the double arithmetic works. */ + +const inf = 1.0e307 * 1.0e307; const nan = inf-inf; + +/* Predicates to check for inf and nan values. */ + +infp x = case x of x::double = x==inf || x==-inf; _ = 0 end; +nanp x = case x of x::double = not (x==x); _ = 0 end; + /* Direct memory accesses. Use with care ... or else! */ private pointer_get_byte pointer_get_int pointer_get_double This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |