static double result = 0.0;
if (result == 0.0) {
-
+
#if defined(INFINITY) && defined(__STDC_IEC_559__)
result = (double)INFINITY;
/* Force overflow */
result += HUGE_VAL;
}
-
+
# if defined(TRIO_PLATFORM_UNIX)
signal(SIGFPE, signal_handler);
# endif
static double result = 0.0;
if (result == 0.0) {
-
+
#if defined(TRIO_COMPILER_SUPPORTS_C99)
result = nan("");
#elif defined(NAN) && defined(__STDC_IEC_559__)
result = (double)NAN;
-
+
#elif defined(USE_IEEE_754)
result = trio_make_double(ieee_754_qnan_array);
# if defined(TRIO_PLATFORM_UNIX)
void (*signal_handler)(int) = signal(SIGFPE, SIG_IGN);
# endif
-
+
result = trio_pinf() / trio_pinf();
-
+
# if defined(TRIO_PLATFORM_UNIX)
signal(SIGFPE, signal_handler);
# endif
-
+
#endif
}
return result;
* the conservative approach and only use it for UNIX95.
*/
return isnan(number);
-
+
#elif defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB)
/*
* Microsoft Visual C++ and Borland C++ Builder have an _isnan()
int is_special_quantity;
is_special_quantity = trio_is_special_quantity(number, &has_mantissa);
-
+
return (is_special_quantity && has_mantissa);
-
+
#else
/*
* Fallback solution
*/
int status;
double integral, fraction;
-
+
# if defined(TRIO_PLATFORM_UNIX)
void (*signal_handler)(int) = signal(SIGFPE, SIG_IGN);
# endif
-
+
status = (/*
* NaN is the only number which does not compare to itself
*/
((number != 0.0) &&
(fraction = modf(number, &integral),
integral == fraction)));
-
+
# if defined(TRIO_PLATFORM_UNIX)
signal(SIGFPE, signal_handler);
# endif
-
+
return status;
-
+
#endif
}
return isinf(number)
? ((number > 0.0) ? 1 : -1)
: 0;
-
+
#elif defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB)
/*
* Microsoft Visual C++ and Borland C++ Builder have an _fpclass()
int is_special_quantity;
is_special_quantity = trio_is_special_quantity(number, &has_mantissa);
-
+
return (is_special_quantity && !has_mantissa)
? ((number < 0.0) ? -1 : 1)
: 0;
* Fallback solution.
*/
int status;
-
+
# if defined(TRIO_PLATFORM_UNIX)
void (*signal_handler)(int) = signal(SIGFPE, SIG_IGN);
# endif
-
+
double infinity = trio_pinf();
-
+
status = ((number == infinity)
? 1
: ((number == -infinity) ? -1 : 0));
-
+
# if defined(TRIO_PLATFORM_UNIX)
signal(SIGFPE, signal_handler);
# endif
-
+
return status;
-
+
#endif
}
* C99 defines isfinite() as a macro.
*/
return isfinite(number);
-
+
#elif defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB)
/*
* Microsoft Visual C++ and Borland C++ Builder use _finite().
* Fallback solution.
*/
return ((trio_isinf(number) == 0) && (trio_isnan(number) == 0));
-
+
#endif
}
# define TRIO_NEGATIVE_ZERO FP_NEG_ZERO
# define TRIO_POSITIVE_NORMAL FP_POS_NORM
# define TRIO_NEGATIVE_NORMAL FP_NEG_NORM
-
+
# elif defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB)
/*
* Microsoft Visual C++ and Borland C++ Builder have an _fpclass()
# define TRIO_NEGATIVE_ZERO _FPCLASS_NZ
# define TRIO_POSITIVE_NORMAL _FPCLASS_PN
# define TRIO_NEGATIVE_NORMAL _FPCLASS_NN
-
+
# elif defined(FP_PLUS_NORM)
/*
* HP-UX 9.x and 10.x have an fpclassify() function, that is different
*is_negative = (number < 0.0);
return TRIO_FP_NORMAL;
}
-
+
# else
/*
* Fallback solution.
*/
int rc;
-
+
if (number == 0.0) {
/*
* In IEEE 754 the sign of zero is ignored in comparisons, so we
}
*is_negative = (number < 0.0);
return TRIO_FP_NORMAL;
-
+
# endif
#endif
}
double number)
{
int is_negative;
-
+
(void)trio_fpclassify_and_signbit(number, &is_negative);
return is_negative;
}
double number)
{
int dummy;
-
+
return trio_fpclassify_and_signbit(number, &dummy);
}
print_class("NNorm", -1.0);
print_class("PSub", 1.01e-307 - 1.00e-307);
print_class("NSub", 1.00e-307 - 1.01e-307);
-
+
printf("NaN : %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n",
my_nan,
((unsigned char *)&my_nan)[0],
((unsigned char *)&my_ninf)[6],
((unsigned char *)&my_ninf)[7],
trio_isnan(my_ninf), trio_isinf(my_ninf));
-
+
# if defined(TRIO_PLATFORM_UNIX)
signal_handler = signal(SIGFPE, SIG_IGN);
# endif
-
+
my_pinf = DBL_MAX + DBL_MAX;
my_ninf = -my_pinf;
my_nan = my_pinf / my_pinf;
# if defined(TRIO_PLATFORM_UNIX)
signal(SIGFPE, signal_handler);
# endif
-
+
printf("NaN : %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n",
my_nan,
((unsigned char *)&my_nan)[0],
((unsigned char *)&my_ninf)[6],
((unsigned char *)&my_ninf)[7],
trio_isnan(my_ninf), trio_isinf(my_ninf));
-
+
return 0;
}
#endif