# HG changeset patch # User Claus Gittinger # Date 1055891497 -7200 # Node ID 44b2f66791f17fc5d3e9be2c051544da09b931f3 # Parent 521174de046dcdc1c9e6d99d07bc66cd084250f1 isnanf for Win32 diff -r 521174de046d -r 44b2f66791f1 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 $' ! !