isnanf for Win32
authorClaus Gittinger <cg@exept.de>
Wed, 18 Jun 2003 01:11:37 +0200
changeset 7419 44b2f66791f1
parent 7418 521174de046d
child 7420 633c9331da21
isnanf for Win32
ShortFloat.st
--- a/ShortFloat.st	Wed Jun 18 01:11:22 2003 +0200
+++ b/ShortFloat.st	Wed Jun 18 01:11:37 2003 +0200
@@ -63,12 +63,42 @@
  * no finite(x) ?
  * no isnan(x) ?
  */
-# ifndef finite 
-#  define finite(x)     1
+# ifndef isnan
+#  define isnan(x)      \
+        ((((unsigned int *)(&x))[0] == 0x00000000) && \
+         (((unsigned int *)(&x))[1] == 0xFFF80000))
+# endif
+
+# ifndef isnanf
+#  define isnanf(x)      \
+        (((unsigned int *)(&x))[0] == 0xFFC00000)
+# endif
+
+# ifndef isPositiveInfinity
+#  define isPositiveInfinity(x) \
+        ((((unsigned int *)(&x))[0] == 0x00000000) && \
+         (((unsigned int *)(&x))[1] == 0x7FF00000))
 # endif
-# ifndef isnan
-#  define isnan(x)      0
+
+# ifndef isNegativeInfinity
+#  define isPositiveInfinity(x) \
+        ((((unsigned int *)(&x))[0] == 0x00000000) && \
+         (((unsigned int *)(&x))[1] == 0xFFF00000))
 # endif
+
+# ifndef isinf
+#  define isinf(x) \
+        ((((unsigned int *)(&x))[0] == 0x00000000) && \
+         ((((unsigned int *)(&x))[1] & 0x7FF00000) == 0x7FF00000))
+# endif
+
+# ifndef finite
+#  define finite(x) (!isinf(x) && !isnan(x))
+# endif
+
+# define NO_ASINH
+# define NO_ACOSH
+# define NO_ATANH
 #endif
 
 #ifdef realIX
@@ -629,8 +659,13 @@
     float fVal;
 
     fVal = __shortFloatVal(self);
-    if ((fVal >= (float)_MIN_INT) && (fVal <= (float)_MAX_INT)) {
-	RETURN ( __MKSMALLINT( (INT)fVal) );
+#ifdef WIN32
+    if (! isnanf(fVal))    
+#endif
+    {
+        if ((fVal >= (float)_MIN_INT) && (fVal <= (float)_MAX_INT)) {
+            RETURN ( __MKSMALLINT( (INT)fVal) );
+        }
     }
 %}.
     ^ super asInteger
@@ -1423,5 +1458,5 @@
 !ShortFloat class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ShortFloat.st,v 1.78 2003-06-17 16:10:28 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ShortFloat.st,v 1.79 2003-06-17 23:11:37 cg Exp $'
 ! !