On Wed, Jul 26, 2000 at 02:06:01PM +0100, [EMAIL PROTECTED] wrote:
> But why not go the whole way - drop the _NaN member,
> have setNaN() do sthg like the above, & isNaN use isnan()
> from math.h ?

Like this patch for example (against cvs-current) :-)
seems to work - not exhaustively tested

 .robin.


Index: ga/src/Sablot/engine/expr.cpp
===================================================================
RCS file: /usr/local/cvs-master/ga/src/Sablot/engine/expr.cpp,v
retrieving revision 1.5
diff -u -r1.5 expr.cpp
--- ga/src/Sablot/engine/expr.cpp       2000/07/17 15:42:16     1.5
+++ ga/src/Sablot/engine/expr.cpp       2000/07/26 13:29:09
@@ -1004,20 +1004,17 @@
 Number::Number()
 {
     *this = 0.0;
-    _NaN = FALSE;
 }
 
 Number::Number(double y)
 {
     *this = y;
-    _NaN = FALSE;
 }
 
 Number& 
 Number::operator= (double y)
 {
     x = y;
-    _NaN = FALSE;
     return *this;
 };
 
@@ -1026,7 +1023,6 @@
 {
     char *endptr;
     x = strtod((char*) s, &endptr);
-    _NaN = FALSE;
     if (*endptr)
         setNaN();
     return *this;
@@ -1072,23 +1068,28 @@
 Bool Number::isNaN()
 {
 #if defined(__linux__) || defined(__unix)
-    return (Bool) (_NaN || isnan(x));
+    return (Bool) (isnan(x));
 #elif defined(WIN32)
-    return (Bool) (_NaN || _isnan(x));
+    return (Bool) (_isnan(x));
 #else
-    return(_NaN);
+#    error "Don't know how to detect NaN on this platform"
 #endif
 }
 
 Bool Number::isInf()
 {
-    return FALSE;
+#if defined(__linux__) || defined(__unix)
+    return (Bool) ( isinf(x) );
+#elif defined(WIN32)
+    return (Bool) (! _finite(x) );
+#else
+#    error "Don't know how to detect Infinity on this platform"
+#endif
 };
 
 void Number::setNaN()
 {
-    _NaN = TRUE;
-    x = -12345;
+    x = 0.0 / 0;
 }
 
 
@@ -2323,14 +2324,16 @@
     Err(situation, ET_BAD_ARGS_N);
 #define checkArgsCountBetween(x,y) if ((atomsNumber < x) || \
     (atomsNumber > y)) Err(situation, ET_BAD_ARGS_N);
+
+// only check for being a nodeset
 #define checkIsNodeset(x) if (atoms[x] -> type != EX_NODESET)\
-    Err(situation, ET_BAD_ARG_TYPE);
-#define checkIsString(x) if (atoms[x] -> type != EX_STRING)\
     Err(situation, ET_BAD_ARG_TYPE);
-#define checkIsString2(x,y) if ((atoms[x] -> type != EX_STRING) || \
-    (atoms[y] -> type != EX_STRING)) Err(situation, ET_BAD_ARG_TYPE);
-#define checkIsNumber(x) if (atoms[x] -> type != EX_NUMBER)\
-    Err(situation, ET_BAD_ARG_TYPE);
+
+// Everything is a string, in a cosmic sense
+#define checkIsString(x)
+#define checkIsString2(x,y)
+// And also a number, though maybe NaN
+#define checkIsNumber(x)
 
 /*................
 firstOccurence

Reply via email to