Slim down trio

This commit is contained in:
twinaphex 2012-11-17 01:14:40 +01:00
parent 1606fff668
commit 453bc88e4f
2 changed files with 0 additions and 2067 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1041,217 +1041,3 @@ trio_ninf(TRIO_NOARGS)
}
#endif
/**
Generate NaN.
@return Floating-point representation of NaN.
*/
#if defined(TRIO_FUNC_NAN)
TRIO_PUBLIC_NAN double
trio_nan(TRIO_NOARGS)
{
/* Cache the result */
static double nan_value = 0.0;
if (nan_value == 0.0) {
# if defined(TRIO_NAN_C99_FUNCTION) || defined(TRIO_PLATFORM_SYMBIAN)
nan_value = nan("");
# endif
# if defined(TRIO_NAN_C99_MACRO)
nan_value = (double)NAN;
# endif
# if defined(TRIO_NAN_IEEE_754)
nan_value = internal_make_double(ieee_754_qnan_array);
# endif
# if defined(TRIO_NAN_FALLBACK)
/*
* There are several ways to generate NaN. The one used here is
* to divide infinity by infinity. I would have preferred to add
* negative infinity to positive infinity, but that yields wrong
* result (infinity) on FreeBSD.
*
* This may fail if the hardware does not support NaN, or if
* the Invalid Operation floating-point exception is unmasked.
*/
# if defined(TRIO_PLATFORM_UNIX)
void (*signal_handler)(int) = signal(SIGFPE, SIG_IGN);
# endif
nan_value = trio_pinf() / trio_pinf();
# if defined(TRIO_PLATFORM_UNIX)
signal(SIGFPE, signal_handler);
# endif
# endif
}
return nan_value;
}
#endif
/** @} SpecialQuantities */
/*************************************************************************
* For test purposes.
*
* Add the following compiler option to include this test code.
*
* Unix : -DSTANDALONE
* VMS : /DEFINE=(STANDALONE)
*/
#if defined(STANDALONE)
# include <stdio.h>
static TRIO_CONST char *
getClassification
TRIO_ARGS1((type),
int type)
{
switch (type) {
case TRIO_FP_INFINITE:
return "FP_INFINITE";
case TRIO_FP_NAN:
return "FP_NAN";
case TRIO_FP_NORMAL:
return "FP_NORMAL";
case TRIO_FP_SUBNORMAL:
return "FP_SUBNORMAL";
case TRIO_FP_ZERO:
return "FP_ZERO";
default:
return "FP_UNKNOWN";
}
}
static void
print_class
TRIO_ARGS2((prefix, number),
TRIO_CONST char *prefix,
double number)
{
printf("%-6s: %s %-15s %g\n",
prefix,
trio_signbit(number) ? "-" : "+",
getClassification(trio_fpclassify(number)),
number);
}
int main(TRIO_NOARGS)
{
double my_nan;
double my_pinf;
double my_ninf;
# if defined(TRIO_PLATFORM_UNIX)
void (*signal_handler) TRIO_PROTO((int));
# endif
my_nan = trio_nan();
my_pinf = trio_pinf();
my_ninf = trio_ninf();
print_class("Nan", my_nan);
print_class("PInf", my_pinf);
print_class("NInf", my_ninf);
print_class("PZero", 0.0);
print_class("NZero", -0.0);
print_class("PNorm", 1.0);
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, %2d)\n",
my_nan,
((unsigned char *)&my_nan)[0],
((unsigned char *)&my_nan)[1],
((unsigned char *)&my_nan)[2],
((unsigned char *)&my_nan)[3],
((unsigned char *)&my_nan)[4],
((unsigned char *)&my_nan)[5],
((unsigned char *)&my_nan)[6],
((unsigned char *)&my_nan)[7],
trio_isnan(my_nan), trio_isinf(my_nan), trio_isfinite(my_nan));
printf("PInf: %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d, %2d)\n",
my_pinf,
((unsigned char *)&my_pinf)[0],
((unsigned char *)&my_pinf)[1],
((unsigned char *)&my_pinf)[2],
((unsigned char *)&my_pinf)[3],
((unsigned char *)&my_pinf)[4],
((unsigned char *)&my_pinf)[5],
((unsigned char *)&my_pinf)[6],
((unsigned char *)&my_pinf)[7],
trio_isnan(my_pinf), trio_isinf(my_pinf), trio_isfinite(my_pinf));
printf("NInf: %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d, %2d)\n",
my_ninf,
((unsigned char *)&my_ninf)[0],
((unsigned char *)&my_ninf)[1],
((unsigned char *)&my_ninf)[2],
((unsigned char *)&my_ninf)[3],
((unsigned char *)&my_ninf)[4],
((unsigned char *)&my_ninf)[5],
((unsigned char *)&my_ninf)[6],
((unsigned char *)&my_ninf)[7],
trio_isnan(my_ninf), trio_isinf(my_ninf), trio_isfinite(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, %2d)\n",
my_nan,
((unsigned char *)&my_nan)[0],
((unsigned char *)&my_nan)[1],
((unsigned char *)&my_nan)[2],
((unsigned char *)&my_nan)[3],
((unsigned char *)&my_nan)[4],
((unsigned char *)&my_nan)[5],
((unsigned char *)&my_nan)[6],
((unsigned char *)&my_nan)[7],
trio_isnan(my_nan), trio_isinf(my_nan), trio_isfinite(my_nan));
printf("PInf: %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d, %2d)\n",
my_pinf,
((unsigned char *)&my_pinf)[0],
((unsigned char *)&my_pinf)[1],
((unsigned char *)&my_pinf)[2],
((unsigned char *)&my_pinf)[3],
((unsigned char *)&my_pinf)[4],
((unsigned char *)&my_pinf)[5],
((unsigned char *)&my_pinf)[6],
((unsigned char *)&my_pinf)[7],
trio_isnan(my_pinf), trio_isinf(my_pinf), trio_isfinite(my_pinf));
printf("NInf: %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d, %2d)\n",
my_ninf,
((unsigned char *)&my_ninf)[0],
((unsigned char *)&my_ninf)[1],
((unsigned char *)&my_ninf)[2],
((unsigned char *)&my_ninf)[3],
((unsigned char *)&my_ninf)[4],
((unsigned char *)&my_ninf)[5],
((unsigned char *)&my_ninf)[6],
((unsigned char *)&my_ninf)[7],
trio_isnan(my_ninf), trio_isinf(my_ninf), trio_isfinite(my_ninf));
return 0;
}
#endif