X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f X-Recipient: djgpp-workers AT delorie DOT com X-Authenticated: #27081556 X-Provags-ID: V01U2FsdGVkX1/3Uls6CYT3Fr3qz6slJP/+NzEmtQs1wpwApk9enX UUPCHEY3X4EJr4 Message-ID: <5144CFCF.4000602@gmx.de> Date: Sat, 16 Mar 2013 21:02:23 +0100 From: Juan Manuel Guerrero User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121025 Thunderbird/16.0.2 MIME-Version: 1.0 To: djgpp-workers AT delorie DOT com Subject: Implementation of isgreater, isgreaterequal, isless, islessequal, islessgreater and isunordered C99 macros. Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 Reply-To: djgpp-workers AT delorie DOT com Some years ago I suggested a patch to implement the C99 is* family of macros. For some reason I have forgot to commit it. Here is it again. Suggestions, objections, comments are welcome. If I do not get any response I will commit it. Regards, Juan M. Guerrero #cvs ci -m"Added is* family of macros." djgpp/include/math.h #cvs ci -m"Added info about is* family of macros." djgpp/src/docs/kb/wc204.txi #cvs ci -m"Describtion of is* family of macros." djgpp/src/libc/c99/math/ismacros.txh #cvs ci -m"Added test file for is* family of macros." djgpp/tests/libc/c99/math/makefile #cvs ci -m"Test file for is* family of macros." djgpp/tests/libc/c99/math/t-ismac.c diff -aprNU5 djgpp.orig/include/math.h djgpp/include/math.h --- djgpp.orig/include/math.h 2013-03-05 19:18:12 +0000 +++ djgpp/include/math.h 2013-03-16 20:03:00 +0000 @@ -106,24 +106,51 @@ extern float __dj_nan; #define FP_SUBNORMAL 0x00000008 #define FP_ZERO 0x00000010 /* Extended with Unnormals (for long doubles). */ #define FP_UNNORMAL 0x00010000 -#define fpclassify(x) ((sizeof(x)==sizeof(float))? __fpclassifyf(x) : \ - (sizeof(x)==sizeof(double))? __fpclassifyd(x) : \ - __fpclassifyld(x)) +#define fpclassify(x) (__extension__ ({__typeof__(x) __xfp = (x); \ + (sizeof(__xfp) == sizeof(float)) ? __fpclassifyf(__xfp) : \ + (sizeof(__xfp) == sizeof(double)) ? __fpclassifyd(__xfp) : \ + __fpclassifyld(__xfp); \ + })) -#define signbit(x) (__extension__ ({__typeof__(x) __x = (x); \ - (sizeof(__x) == sizeof(float)) ? __signbitf(__x) : \ - (sizeof(__x) == sizeof(double)) ? __signbitd(__x) : \ - __signbitld(__x); \ - })) +#define signbit(x) (__extension__ ({__typeof__(x) __xsb = (x); \ + (sizeof(__xsb) == sizeof(float)) ? __signbitf(__xsb) : \ + (sizeof(__xsb) == sizeof(double)) ? __signbitd(__xsb) : \ + __signbitld(__xsb); \ + })) -#define isfinite(x) ((fpclassify(x) & (FP_NORMAL | FP_SUBNORMAL | FP_ZERO)) != 0) -#define isinf(x) (fpclassify(x) == FP_INFINITE) -#define isnan(x) (fpclassify(x) == FP_NAN) -#define isnormal(x) (fpclassify(x) == FP_NORMAL) +#define isfinite(x) ((fpclassify(x) & (FP_NORMAL | FP_SUBNORMAL | FP_ZERO)) != 0) +#define isinf(x) (fpclassify(x) == FP_INFINITE) +#define isnan(x) (fpclassify(x) == FP_NAN) +#define isnormal(x) (fpclassify(x) == FP_NORMAL) + +#define isgreater(x, y) (__extension__ ({__typeof__(x) __x_ig = (x); \ + __typeof__(y) __y_ig = (y); \ + !isunordered(__x_ig, __y_ig) && (__x_ig > __y_ig); \ + })) +#define isgreaterequal(x, y) (__extension__ ({__typeof__(x) __x_ige = (x); \ + __typeof__(y) __y_ige = (y); \ + !isunordered(__x_ige, __y_ige) && (__x_ige >= __y_ige); \ + })) +#define isless(x, y) (__extension__ ({__typeof__(x) __x_il = (x); \ + __typeof__(y) __y_il = (y); \ + !isunordered(__x_il, __y_il) && (__x_il < __y_il); \ + })) +#define islessequal(x, y) (__extension__ ({__typeof__(x) __x_ile = (x); \ + __typeof__(y) __y_ile = (y); \ + !isunordered(__x_ile, __y_ile) && (__x_ile <= __y_ile); \ + })) +#define islessgreater(x, y) (__extension__ ({__typeof__(x) __x_ilg = (x); \ + __typeof__(y) __y_ilg = (y); \ + !isunordered(__x_ilg, __y_ilg) && (__x_ilg < __y_ilg || __x_ilg > __y_ilg); \ + })) +#define isunordered(x, y) (__extension__ ({__typeof__(x) __x_iu = (x); \ + __typeof__(y) __y_iu = (y); \ + (fpclassify(__x_iu) == FP_NAN) || (fpclassify(__y_iu) == FP_NAN); \ + })) int __fpclassifyf(float) __attribute__((const)); int __fpclassifyd(double) __attribute__((const)); int __fpclassifyld(long double) __attribute__((const)); double nan(const char *); diff -aprNU5 djgpp.orig/src/docs/kb/wc204.txi djgpp/src/docs/kb/wc204.txi --- djgpp.orig/src/docs/kb/wc204.txi 2013-01-27 23:26:04 +0000 +++ djgpp/src/docs/kb/wc204.txi 2013-03-16 20:03:00 +0000 @@ -1272,5 +1272,20 @@ by @code{_doscan} and the @code{scanf} f @tindex rlim_t @tindex struct rlimit AT r{, and }rlim_t The type @code{rlim_t} has been added. @code{rlim_t} is now used for the @code{rlim_cur} and @code{rlim_max} members of @code{struct rlimit}. + +@cindex @acronym{C99} compliance, @code{math.h} +@findex isfinite AT r{ added} +@findex isinf AT r{ added} +@findex isnan AT r{ added} +@findex isnormal AT r{ added} +@findex isgreater AT r{ added} +@findex isgreaterequal AT r{ added} +@findex isless AT r{ added} +@findex islessequal AT r{ added} +@findex islessgreater AT r{ added} +@findex isunordered AT r{ added} +The @acronym{C99} macros @code{isfinite}, @code{isinf}, @code{isnan}, @code{isnormal}, @code{isgreater}, +@code{isgreaterequal}, @code{isless}, @code{islessequal}, @code{islessgreater} and @code{isunordered} +were added to comply with the @acronym{C99} standard. diff -aprNU5 djgpp.orig/src/libc/c99/math/ismacros.txh djgpp/src/libc/c99/math/ismacros.txh --- djgpp.orig/src/libc/c99/math/ismacros.txh 1970-01-01 00:00:00 +0000 +++ djgpp/src/libc/c99/math/ismacros.txh 2013-03-16 20:03:02 +0000 @@ -0,0 +1,422 @@ +@node isfinite, math +@findex isfinite +@subheading Syntax + +@example +#include + +int isfinite(x); +@end example + +@subheading Description + +The macro @code{isfinite} will determine whether its argument @var{x} has a finite +value (zero, subnormal, or normal, and not infinite or NaN). The operands can be +of any real floating-point type. + +@subheading Return Value + +non-zero for a finite value; +zero else. + +@subheading Portability + +@portability !ansi-c89, ansi-c99 + +@subheading Example + +@example +long double ld = 3.14159265358979; + +if (isfinite(ld)) + printf("value is finite.\n"); +else if (isinf(ld)) + printf("value is infinite.\n"); +else if (isnan(ld)) + printf("value is NaN.\n"); + +@end example + +@c ---------------------------------------------------------------------- +@node isgreater, math +@findex isgreater +@subheading Syntax + +@example +#include + +int isgreater(x, y); +@end example + +@subheading Description + +The macro @code{isgreater} will determine whether its first argument @var{x} is +greater than its second argument @var{y} without failing if one of the operands is +@code{NaN}. The operands can be of any real floating-point type and the macro is +guaranteed to evaluate their operands only once. + +@subheading Return Value + +zero if one of @var{x} or @var{y} is @code{NaN}; +else the result of (@var{x}) > (@var{y}). + +@subheading Portability + +@portability !ansi-c89, ansi-c99 + +@subheading Example + +@example +float f = 1; +double d = INFINITY; + +if (isnan(f) || isnan(d)) + printf("f or d is NaN.\n"); +else +@{ + if (isgreater(f, d)) + printf("f is greater than d.\n"); + else + printf("f is not greater than d.\n"); +@} + +@end example + +@c ---------------------------------------------------------------------- +@node isgreaterequal, math +@findex isgreaterequal +@subheading Syntax + +@example +#include + +int isgreaterequal(x, y); +@end example + +@subheading Description + +The macro @code{isgreaterequal} will determine whether its first argument @var{x} is +greater than or equal to its second argument @var{y} without failing if one of the operands +is @code{NaN}. The operands can be of any real floating-point type and the macro is +guaranteed to evaluate their operands only once. + +@subheading Return Value + +zero if one of @var{x} or @var{y} is @code{NaN}; +else the result of (@var{x}) >= (@var{y}). + +@subheading Portability + +@portability !ansi-c89, ansi-c99 + +@subheading Example + +@example +float f = 1; +double d = INFINITY; + +if (isnan(f) || isnan(d)) + printf("f or d is NaN.\n"); +else +@{ + if (isgreaterequal(f, d)) + printf("f is greater than or equal to d.\n"); + else + printf("f is not greater than d.\n"); +@} + +@end example + +@c ---------------------------------------------------------------------- +@node isinf, math +@findex isinf +@subheading Syntax + +@example +#include + +int isinf(x); +@end example + +@subheading Description + +The macro @code{isinf} will determine whether its argument @var{x} value is a positive +or negative infinity. The operands can be of any real floating-point type. + +@subheading Return Value + +non-zero for a infinite value (positive or negative); +zero else. + +@subheading Portability + +@portability !ansi-c89, ansi-c99 + +@subheading Example + +@example +double d = INFINITY; + +if (isinf(d)) + printf("value is infinite.\n"); +else if (isnan(d)) + printf("value is NaN.\n"); +else + printf("value is finite.\n"); + +@end example + +@c ---------------------------------------------------------------------- +@node isless, math +@findex isless +@subheading Syntax + +@example +#include + +int isless(x, y); +@end example + +@subheading Description + +The macro @code{isless} will determine whether its first argument @var{x} is less than +its second argument @var{y} without failing if one of the operands is @code{NaN}. The +operands can be of any real floating-point type and the macro is guaranteed to evaluate +their operands only once. + +@subheading Return Value + +zero if one of @var{x} or @var{y} is @code{NaN}; +else the result of (@var{x}) < (@var{y}). + +@subheading Portability + +@portability !ansi-c89, ansi-c99 + +@subheading Example + +@example +float f = 1; +double d = INFINITY; + +if (isnan(f) || isnan(d)) + printf("f or d is NaN.\n"); +else +@{ + if (isless(f, d)) + printf("f is less than d.\n"); + else + printf("f is not less than d.\n"); +@} + +@end example + +@c ---------------------------------------------------------------------- +@node islessequal, math +@findex islessequal +@subheading Syntax + +@example +#include + +int islessequal(x, y); +@end example + +@subheading Description + +The macro @code{islessequal} will determine whether its first argument @var{x} is less +than or equal to its second argument @var{y} without failing if one of the operands is +@code{NaN}. The operands can be of any real floating-point type and the macro is +guaranteed to evaluate their operands only once. + +@subheading Return Value + +zero if one of @var{x} or @var{y} is @code{NaN}; +else the result of (@var{x}) <= (@var{y}). + +@subheading Portability + +@portability !ansi-c89, ansi-c99 + +@subheading Example + +@example +float f = 1; +double d = INFINITY; + +if (isnan(f) || isnan(d)) + printf("f or d is NaN.\n"); +else +@{ + if (islessequal(f, d)) + printf("f is less than or equal to d.\n"); + else + printf("f is not less than d.\n"); +@} + +@end example + +@c ---------------------------------------------------------------------- +@node islessgreater, math +@findex islessgreater +@subheading Syntax + +@example +#include + +int islessgreater(x, y); +@end example + +@subheading Description + +The macro @code{islessgreater} will determine whether its first argument @var{x} is less +than or greater than its second argument @var{y} without failing if one of the operands +is @code{NaN}. The operands can be of any real floating-point type and the macro is +guaranteed to evaluate their operands only once. + +@subheading Return Value + +zero if one of @var{x} or @var{y} is @code{NaN}; +else the result of (@var{x}) < (@var{y}) || (@var{x}) > (@var{y}). + +@subheading Portability + +@portability !ansi-c89, ansi-c99 + +@subheading Example + +@example +double d = 1; +long double ld = 1; + +if (isnan(ld) || isnan(d)) + printf("ld or d is NaN.\n"); +else +@{ + if (islessgreater(lf, d)) + printf("ld is less than d or ld is greater than d.\n"); + else + printf("ld is equal to d.\n"); +@} + +@end example + +@c ---------------------------------------------------------------------- +@node isnan, math +@findex isnan +@subheading Syntax + +@example +#include + +int isnan(x); +@end example + +@subheading Description + +The macro @code{isnan} will determine whether its argument @var{x} is a NaN. The operands +can be of any real floating-point type. + +@subheading Return Value + +non-zero for NaN; +zero else. + +@subheading Portability + +@portability !ansi-c89, ansi-c99 + +@subheading Example + +@example +float f = NAN; + +if (isnan(f)) + printf("value is NaN.\n"); +else if (isinf(f)) + printf("value is infinite.\n"); +else + printf("value is finite.\n"); + +@end example + +@c ---------------------------------------------------------------------- +@node isnormal, math +@findex isnormal +@subheading Syntax + +@example +#include + +int isnormal(x); +@end example + +@subheading Description + +The macro @code{isnormal} will determine whether its argument @var{x} is normal +(neither zero, subnormal, infinite nor NaN). The operands can be of any real +floating-point type. + +@subheading Return Value + +non-zero for a normal value; +zero else. + +@subheading Portability + +@portability !ansi-c89, ansi-c99 + +@subheading Example + +@example +long double ld = 3.14159265358979; + +if (isfinite(ld)) +@{ + if (isnormal(ld)) + printf("value is normal.\n"); + else + printf("value is either zero or subnormal.\n"); +@} +else + printf("value is either infinity or NaN.\n"); + +@end example + +@c ---------------------------------------------------------------------- +@node isunordered, math +@findex isunordered +@subheading Syntax + +@example +#include + +int isunordered(x); +@end example + +@subheading Description + +The macro @code{isunordered} will determine whether its arguments @var{x} or @var{y} are unordered. +The operands can be of any real floating-point type. + +@subheading Return Value + +non-zero if one of @var{x} or @var{y} is @code{NaN}; +zero else. + +@subheading Portability + +@portability !ansi-c89, ansi-c99 + +@subheading Example + +@example +float pi = 3.14159; +long double x = NAN; + +if (isunordered(pi, x)) + printf("one of the values is NaN.\n"); + +@end example + +@c ---------------------------------------------------------------------- diff -aprNU5 djgpp.orig/tests/libc/c99/math/makefile djgpp/tests/libc/c99/math/makefile --- djgpp.orig/tests/libc/c99/math/makefile 2003-10-25 11:22:52 +0000 +++ djgpp/tests/libc/c99/math/makefile 2013-03-16 20:03:38 +0000 @@ -1,7 +1,8 @@ TOP=../.. SRC += t-fpclas.c SRC += t-nan.c SRC += t-nan2.c +SRC += t-ismac.c include $(TOP)/../makefile.inc diff -aprNU5 djgpp.orig/tests/libc/c99/math/t-ismac.c djgpp/tests/libc/c99/math/t-ismac.c --- djgpp.orig/tests/libc/c99/math/t-ismac.c 1970-01-01 00:00:00 +0000 +++ djgpp/tests/libc/c99/math/t-ismac.c 2013-03-16 20:05:36 +0000 @@ -0,0 +1,1624 @@ +#include "../../../../include/stdio.h" +#include "../../../../include/math.h" +#include "../../../../include/libc/ieee.h" +#include + +#define TEST_TYPE 0 /* Allowed 0 or 1 */ + + +typedef union +{ + long_double_t ldt; + long double ld; +} test_long_double_union_t; + +typedef struct { + const char *class; + const char *type; + test_long_double_union_t number; +} test_long_double_t; + + +typedef union +{ + double_t dt; + double d; +} test_double_union_t; + +typedef struct { + const char *class; + const char *type; + test_double_union_t number; +} test_double_t; + + +typedef union +{ + float_t ft; + float f; +} test_float_union_t; + +typedef struct { + const char *class; + const char *type; + test_float_union_t number; +} test_float_t; + + +int main(void) +{ + bool test_passed; + int i; + + test_long_double_t test_ld[] = { + /* Normals. (4) */ + {"long double", "small positive normal", {{1, 0x80000000, 1, 0}}}, /* Smallest possible > 0. */ + {"long double", "small negative normal", {{1, 0x80000000, 1, 1}}}, /* Biggest possible < 0. */ + {"long double", "big positive normal", {{0xFFFFFFFF, 0xFFFFFFFF, 0x7FFE, 0}}}, /* Big number. */ + {"long double", "big negative normal", {{0xFFFFFFFF, 0xFFFFFFFF, 0x7FFE, 1}}}, /* Big -number. */ + + /* Subnormals aka denormals. (4 + 2) */ + {"long double", "positive subnormal", {{1, 0, 0, 0}}}, /* Smallest possible > 0. */ + {"long double", "negative subnormal", {{1, 0, 0, 1}}}, /* Biggest possible < 0. */ + + /* Zeros. (4 + 2 + 2) */ + {"long double", "positive zero", {{0, 0, 0, 0 }}}, /* 0.0 */ + {"long double", "negative zero", {{0, 0, 0, 1 }}}, /* -0.0 */ + + /* Infinities. (4 + 2 + 2 + 2) */ + {"long double", "positive infinity", {{0, 0x80000000, 0x7FFF, 0}}}, /* Inf. */ + {"long double", "negative infinity", {{0, 0x80000000, 0x7FFF, 1}}}, /* -Inf. */ + + /* NaNs. (4 + 2 + 2 + 2 + 4) */ + {"long double", "positive signalling NaN", {{1, 0x80000000, 0x7FFF, 0}}}, /* SNaN */ + {"long double", "negative signalling NaN", {{1, 0x80000000, 0x7FFF, 1}}}, /* -SNaN */ + {"long double", "positive quiet NaN", {{0, 0xFFFFFFFF, 0x7FFF, 0}}}, /* QNaN */ + {"long double", "negative quiet NaN", {{0, 0xFFFFFFFF, 0x7FFF, 1}}} /* -QNaN */ + }; + + test_double_t test_d[] = { + /* Normals. */ + {"double", "small positive normal", {{1, 0, 1, 0}}}, /* Small number. */ + {"double", "small negative normal", {{1, 0, 1, 1}}}, /* Small -number. */ + {"double", "big positive normal", {{0xFFFFFFFF, 0x7FFFF, 0x7FE, 0}}}, /* Big number. */ + {"double", "big negative normal", {{0xFFFFFFFF, 0x7FFFF, 0x7FE, 1}}}, /* Big -number. */ + + /* Subnormals aka denormals. */ + {"double", "positive subnormal", {{1, 0, 0, 0}}}, /* Very small number. */ + {"double", "negative subnormal", {{1, 0, 0, 1}}}, /* Very small -number. */ + + /* Zeros. */ + {"double", "positive zero", {{0, 0, 0, 0}}}, /* 0.0 */ + {"double", "negative zero", {{0, 0, 0, 1}}}, /* -0.0 */ + + /* Infinities. */ + {"double", "positive infinity", {{0, 0, 0x7FF, 0}}}, /* Inf. */ + {"double", "negative infinity", {{0, 0, 0x7FF, 1}}}, /* -Inf. */ + + /* NaNs. */ + {"double", "positive signalling NaN", {{1, 0, 0x7FF, 0}}}, /* SNaN */ + {"double", "negative signalling NaN", {{1, 0, 0x7FF, 1}}}, /* -SNaN */ + {"double", "positive quiet NaN", {{0, 0xFFFFF, 0x7FF, 0}}}, /* QNaN */ + {"double", "negative quiet NaN", {{0, 0xFFFFF, 0x7FF, 1}}} /* -QNaN */ + }; + + test_float_t test_f[] = { + /* Normals. */ + {"float", "small positive normal", {{1, 1, 0}}}, /* Small number. */ + {"float", "small negative normal", {{1, 1, 1}}}, /* Small -number. */ + {"float", "big positive normal", {{0xFF, 0xFE, 0}}}, /* Big number. */ + {"float", "big negative normal", {{0xFF, 0xFE, 1}}}, /* Big -number. */ + + /* Subnormals aka denormals. */ + {"float", "positive subnormal", {{1, 0, 0}}}, /* Very small number. */ + {"float", "negative subnormal", {{1, 0, 1}}}, /* Very small -number. */ + + /* Zeros. */ + {"float", "positive zero", {{0, 0, 0}}}, /* 0.0 */ + {"float", "negative zero", {{0, 0, 1}}}, /* -0.0 */ + + /* Infinities. */ + {"float", "positive infinity", {{0, 0xFF, 0}}}, /* Inf */ + {"float", "negative infinity", {{0, 0xFF, 1}}}, /* -Inf */ + + /* NaNs. */ + {"float", "positive signalling NaN", {{1, 0xFF, 0}}}, /* SNaN */ + {"float", "negative signalling NaN", {{1, 0xFF, 1}}}, /* -SNaN */ + {"float", "positive quiet NaN", {{0x7FFFFF, 0xFF, 0}}}, /* QNaN */ + {"float", "negative quiet NaN", {{0x7FFFFF, 0xFF, 1}}} /* -QNaN */ + }; + + + + /* + * isfinite must return non-zero for normals, subnormals and zero, + * and zero for infinity and NaN. + */ + test_passed = true; + for (i = 0; i < 4; i++) + { + if (!isfinite(test_ld[i].number.ld)) + { + printf("Test failed. Testing isfinite(%La) for a %s %s: %d\n", test_ld[i].number.ld, test_ld[i].class, test_ld[i].type, isfinite(test_ld[i].number.ld)); + break; + } + else if (!isfinite(test_d[i].number.d)) + { + printf("Test failed. Testing isfinite(%a) for a %s %s: %d\n", test_d[i].number.d, test_d[i].class, test_d[i].type, isfinite(test_d[i].number.d)); + break; + } + else if (!isfinite(test_f[i].number.f)) + { + printf("Test failed. Testing isfinite(%a) for a %s %s: %d\n\n", test_f[i].number.f, test_f[i].class, test_f[i].type, isfinite(test_f[i].number.f)); + break; + } + } + if (i < 4) + { + test_passed = false; + printf("isfinite(x) failed for normals.\n"); + } + + for (i = 4; i < 4 + 2; i++) + { + if (!isfinite(test_ld[i].number.ld)) + { + printf("Test failed. Testing isfinite(%La) for a %s %s: %d\n", test_ld[i].number.ld, test_ld[i].class, test_ld[i].type, isfinite(test_ld[i].number.ld)); + break; + } + else if (!isfinite(test_d[i].number.d)) + { + printf("Test failed. Testing isfinite(%a) for a %s %s: %d\n", test_d[i].number.d, test_d[i].class, test_d[i].type, isfinite(test_d[i].number.d)); + break; + } + else if (!isfinite(test_f[i].number.f)) + { + printf("Test failed. Testing isfinite(%a) for a %s %s: %d\n\n", test_f[i].number.f, test_f[i].class, test_f[i].type, isfinite(test_f[i].number.f)); + break; + } + } + if (i < 4 + 2) + { + test_passed = false; + printf("isfinite(x) failed for subnormals aka denormals.\n"); + } + + for (i = 4 + 2; i < 4 + 2 + 2; i++) + { + if (!isfinite(test_ld[i].number.ld)) + { + printf("Test failed. Testing isfinite(%La) for a %s %s: %d\n", test_ld[i].number.ld, test_ld[i].class, test_ld[i].type, isfinite(test_ld[i].number.ld)); + break; + } + else if (!isfinite(test_d[i].number.d)) + { + printf("Test failed. Testing isfinite(%a) for a %s %s: %d\n", test_d[i].number.d, test_d[i].class, test_d[i].type, isfinite(test_d[i].number.d)); + break; + } + else if (!isfinite(test_f[i].number.f)) + { + printf("Test failed. Testing isfinite(%a) for a %s %s: %d\n\n", test_f[i].number.f, test_f[i].class, test_f[i].type, isfinite(test_f[i].number.f)); + break; + } + } + if (i < 4 + 2 + 2) + { + test_passed = false; + printf("isfinite(x) failed for zero.\n"); + } + + for (i = 4 + 2 + 2; i < 4 + 2 + 2 + 2; i++) + { + if (isfinite(test_ld[i].number.ld)) + { + printf("Test failed. Testing isfinite(%La) for a %s %s: %d\n", test_ld[i].number.ld, test_ld[i].class, test_ld[i].type, isfinite(test_ld[i].number.ld)); + break; + } + else if (isfinite(test_d[i].number.d)) + { + printf("Test failed. Testing isfinite(%a) for a %s %s: %d\n", test_d[i].number.d, test_d[i].class, test_d[i].type, isfinite(test_d[i].number.d)); + break; + } + else if (isfinite(test_f[i].number.f)) + { + printf("Test failed. Testing isfinite(%a) for a %s %s: %d\n\n", test_f[i].number.f, test_f[i].class, test_f[i].type, isfinite(test_f[i].number.f)); + break; + } + } + if (i < 4 + 2 + 2 + 2) + { + test_passed = false; + printf("isfinite(x) failed for infinity.\n"); + } + + for (i = 4 + 2 + 2 + 2; i < 4 + 2 + 2 + 2 + 4; i++) + { + if (isfinite(test_ld[i].number.ld)) + { + printf("Test failed. Testing isfinite(%La) for a %s %s: %d\n", test_ld[i].number.ld, test_ld[i].class, test_ld[i].type, isfinite(test_ld[i].number.ld)); + break; + } + else if (isfinite(test_d[i].number.d)) + { + printf("Test failed. Testing isfinite(%a) for a %s %s: %d\n", test_d[i].number.d, test_d[i].class, test_d[i].type, isfinite(test_d[i].number.d)); + break; + } + else if (isfinite(test_f[i].number.f)) + { + printf("Test failed. Testing isfinite(%a) for a %s %s: %d\n\n", test_f[i].number.f, test_f[i].class, test_f[i].type, isfinite(test_f[i].number.f)); + break; + } + } + if (i < 4 + 2 + 2 + 2 + 4) + { + test_passed = false; + printf("isfinite(x) failed for SNaN and/or QNaN.\n"); + } + else if (test_passed) + printf("isfinite(x) passed all tests.\n"); + printf("----------------------------------------------------------------------\n"); + + + + /* + * isnormal must return non-zero for normals + * and zero for subnormals, zero, infinity and NaN. + */ + test_passed = true; + for (i = 0; i < 4; i++) + { + if (!isnormal(test_ld[i].number.ld)) + { + printf("Test failed. Testing isnormal(%La) for a %s %s: %d\n", test_ld[i].number.ld, test_ld[i].class, test_ld[i].type, isnormal(test_ld[i].number.ld)); + break; + } + else if (!isnormal(test_d[i].number.d)) + { + printf("Test failed. Testing isnormal(%a) for a %s %s: %d\n", test_d[i].number.d, test_d[i].class, test_d[i].type, isnormal(test_d[i].number.d)); + break; + } + else if (!isnormal(test_f[i].number.f)) + { + printf("Test failed. Testing isnormal(%a) for a %s %s: %d\n\n", test_f[i].number.f, test_f[i].class, test_f[i].type, isnormal(test_f[i].number.f)); + break; + } + } + if (i < 4) + { + test_passed = false; + printf("isnormal(x) failed for normals.\n"); + } + + for (i = 4; i < 4 + 2; i++) + { + if (isnormal(test_ld[i].number.ld)) + { + printf("Test failed. Testing isnormal(%La) for a %s %s: %d\n", test_ld[i].number.ld, test_ld[i].class, test_ld[i].type, isnormal(test_ld[i].number.ld)); + break; + } + else if (isnormal(test_d[i].number.d)) + { + printf("Test failed. Testing isnormal(%a) for a %s %s: %d\n", test_d[i].number.d, test_d[i].class, test_d[i].type, isnormal(test_d[i].number.d)); + break; + } + else if (isnormal(test_f[i].number.f)) + { + printf("Test failed. Testing isnormal(%a) for a %s %s: %d\n\n", test_f[i].number.f, test_f[i].class, test_f[i].type, isnormal(test_f[i].number.f)); + break; + } + } + if (i < 4 + 2) + { + test_passed = false; + printf("isnormal(x) failed for subnormals aka denormals.\n"); + } + + for (i = 4 + 2; i < 4 + 2 + 2; i++) + { + if (isnormal(test_ld[i].number.ld)) + { + printf("Test failed. Testing isnormal(%La) for a %s %s: %d\n", test_ld[i].number.ld, test_ld[i].class, test_ld[i].type, isnormal(test_ld[i].number.ld)); + break; + } + else if (isnormal(test_d[i].number.d)) + { + printf("Test failed. Testing isnormal(%a) for a %s %s: %d\n", test_d[i].number.d, test_d[i].class, test_d[i].type, isnormal(test_d[i].number.d)); + break; + } + else if (isnormal(test_f[i].number.f)) + { + printf("Test failed. Testing isnormal(%a) for a %s %s: %d\n\n", test_f[i].number.f, test_f[i].class, test_f[i].type, isnormal(test_f[i].number.f)); + break; + } + } + if (i < 4 + 2 + 2) + { + test_passed = false; + printf("isnormal(x) failed for zero.\n"); + } + + for (i = 4 + 2 + 2; i < 4 + 2 + 2 + 2; i++) + { + if (isnormal(test_ld[i].number.ld)) + { + printf("Test failed. Testing isnormal(%La) for a %s %s: %d\n", test_ld[i].number.ld, test_ld[i].class, test_ld[i].type, isnormal(test_ld[i].number.ld)); + break; + } + else if (isnormal(test_d[i].number.d)) + { + printf("Test failed. Testing isnormal(%a) for a %s %s: %d\n", test_d[i].number.d, test_d[i].class, test_d[i].type, isnormal(test_d[i].number.d)); + break; + } + else if (isnormal(test_f[i].number.f)) + { + printf("Test failed. Testing isnormal(%a) for a %s %s: %d\n\n", test_f[i].number.f, test_f[i].class, test_f[i].type, isnormal(test_f[i].number.f)); + break; + } + } + if (i < 4 + 2 + 2 + 2) + { + test_passed = false; + printf("isnormal(x) failed for infinity.\n"); + } + + for (i = 4 + 2 + 2 + 2; i < 4 + 2 + 2 + 2 + 4; i++) + { + if (isnormal(test_ld[i].number.ld)) + { + printf("Test failed. Testing isnormal(%La) for a %s %s: %d\n", test_ld[i].number.ld, test_ld[i].class, test_ld[i].type, isnormal(test_ld[i].number.ld)); + break; + } + else if (isnormal(test_d[i].number.d)) + { + printf("Test failed. Testing isnormal(%a) for a %s %s: %d\n", test_d[i].number.d, test_d[i].class, test_d[i].type, isnormal(test_d[i].number.d)); + break; + } + else if (isnormal(test_f[i].number.f)) + { + printf("Test failed. Testing isnormal(%a) for a %s %s: %d\n\n", test_f[i].number.f, test_f[i].class, test_f[i].type, isnormal(test_f[i].number.f)); + break; + } + } + if (i < 4 + 2 + 2 + 2 + 4) + { + test_passed = false; + printf("isnormal(x) failed for SNaN and/or QNaN.\n"); + } + else if (test_passed) + printf("isnormal(x) passed all tests.\n"); + printf("----------------------------------------------------------------------\n"); + + + + /* + * isinf must return non-zero for infinity (positive or negative) + * and zero else. + */ + test_passed = true; + for (i = 0; i < 4; i++) + { + if (isinf(test_ld[i].number.ld)) + { + printf("Test failed. Testing isinf(%La) for a %s %s: %d\n", test_ld[i].number.ld, test_ld[i].class, test_ld[i].type, isinf(test_ld[i].number.ld)); + break; + } + else if (isinf(test_d[i].number.d)) + { + printf("Test failed. Testing isinf(%a) for a %s %s: %d\n", test_d[i].number.d, test_d[i].class, test_d[i].type, isinf(test_d[i].number.d)); + break; + } + else if (isinf(test_f[i].number.f)) + { + printf("Test failed. Testing isinf(%a) for a %s %s: %d\n\n", test_f[i].number.f, test_f[i].class, test_f[i].type, isinf(test_f[i].number.f)); + break; + } + } + if (i < 4) + { + test_passed = false; + printf("isinf(x) failed for normals.\n"); + } + + for (i = 4; i < 4 + 2; i++) + { + if (isinf(test_ld[i].number.ld)) + { + printf("Test failed. Testing isinf(%La) for a %s %s: %d\n", test_ld[i].number.ld, test_ld[i].class, test_ld[i].type, isinf(test_ld[i].number.ld)); + break; + } + else if (isinf(test_d[i].number.d)) + { + printf("Test failed. Testing isinf(%a) for a %s %s: %d\n", test_d[i].number.d, test_d[i].class, test_d[i].type, isinf(test_d[i].number.d)); + break; + } + else if (isinf(test_f[i].number.f)) + { + printf("Test failed. Testing isinf(%a) for a %s %s: %d\n\n", test_f[i].number.f, test_f[i].class, test_f[i].type, isinf(test_f[i].number.f)); + break; + } + } + if (i < 4 + 2) + { + test_passed = false; + printf("isinf(x) failed for subnormals aka denormals.\n"); + } + + for (i = 4 + 2; i < 4 + 2 + 2; i++) + { + if (isinf(test_ld[i].number.ld)) + { + printf("Test failed. Testing isinf(%La) for a %s %s: %d\n", test_ld[i].number.ld, test_ld[i].class, test_ld[i].type, isinf(test_ld[i].number.ld)); + break; + } + else if (isinf(test_d[i].number.d)) + { + printf("Test failed. Testing isinf(%a) for a %s %s: %d\n", test_d[i].number.d, test_d[i].class, test_d[i].type, isinf(test_d[i].number.d)); + break; + } + else if (isinf(test_f[i].number.f)) + { + printf("Test failed. Testing isinf(%a) for a %s %s: %d\n\n", test_f[i].number.f, test_f[i].class, test_f[i].type, isinf(test_f[i].number.f)); + break; + } + } + if (i < 4 + 2 + 2) + { + test_passed = false; + printf("isinf(x) failed for zero.\n"); + } + + for (i = 4 + 2 + 2; i < 4 + 2 + 2 + 2; i++) + { + if (!isinf(test_ld[i].number.ld)) + { + printf("Test failed. Testing isinf(%La) for a %s %s: %d\n", test_ld[i].number.ld, test_ld[i].class, test_ld[i].type, isinf(test_ld[i].number.ld)); + break; + } + else if (!isinf(test_d[i].number.d)) + { + printf("Test failed. Testing isinf(%a) for a %s %s: %d\n", test_d[i].number.d, test_d[i].class, test_d[i].type, isinf(test_d[i].number.d)); + break; + } + else if (!isinf(test_f[i].number.f)) + { + printf("Test failed. Testing isinf(%a) for a %s %s: %d\n\n", test_f[i].number.f, test_f[i].class, test_f[i].type, isinf(test_f[i].number.f)); + break; + } + } + if (i < 4 + 2 + 2 + 2) + { + test_passed = false; + printf("isinf(x) failed for infinity.\n"); + } + + for (i = 4 + 2 + 2 + 2; i < 4 + 2 + 2 + 2 + 4; i++) + { + if (isinf(test_ld[i].number.ld)) + { + printf("Test failed. Testing isinf(%La) for a %s %s: %d\n", test_ld[i].number.ld, test_ld[i].class, test_ld[i].type, isinf(test_ld[i].number.ld)); + break; + } + else if (isinf(test_d[i].number.d)) + { + printf("Test failed. Testing isinf(%a) for a %s %s: %d\n", test_d[i].number.d, test_d[i].class, test_d[i].type, isinf(test_d[i].number.d)); + break; + } + else if (isinf(test_f[i].number.f)) + { + printf("Test failed. Testing isinf(%a) for a %s %s: %d\n\n", test_f[i].number.f, test_f[i].class, test_f[i].type, isinf(test_f[i].number.f)); + break; + } + } + if (i < 4 + 2 + 2 + 2 + 4) + { + test_passed = false; + printf("isinf(x) failed for SNaN and/or QNaN.\n"); + } + else if (test_passed) + printf("isinf(x) passed all tests.\n"); + printf("----------------------------------------------------------------------\n"); + + + + /* + * isnan must return non-zero for [SQ]NaN (positive or negative) + * and zero else. + */ + test_passed = true; + for (i = 0; i < 4; i++) + { + if (isnan(test_ld[i].number.ld)) + { + printf("Test failed. Testing isnan(%La) for a %s %s: %d\n", test_ld[i].number.ld, test_ld[i].class, test_ld[i].type, isnan(test_ld[i].number.ld)); + break; + } + else if (isnan(test_d[i].number.d)) + { + printf("Test failed. Testing isnan(%a) for a %s %s: %d\n", test_d[i].number.d, test_d[i].class, test_d[i].type, isnan(test_d[i].number.d)); + break; + } + else if (isnan(test_f[i].number.f)) + { + printf("Test failed. Testing isnan(%a) for a %s %s: %d\n\n", test_f[i].number.f, test_f[i].class, test_f[i].type, isnan(test_f[i].number.f)); + break; + } + } + if (i < 4) + { + test_passed = false; + printf("isnan(x) failed for normals.\n"); + } + + for (i = 4; i < 4 + 2; i++) + { + if (isnan(test_ld[i].number.ld)) + { + printf("Test failed. Testing isnan(%La) for a %s %s: %d\n", test_ld[i].number.ld, test_ld[i].class, test_ld[i].type, isnan(test_ld[i].number.ld)); + break; + } + else if (isnan(test_d[i].number.d)) + { + printf("Test failed. Testing isnan(%a) for a %s %s: %d\n", test_d[i].number.d, test_d[i].class, test_d[i].type, isnan(test_d[i].number.d)); + break; + } + else if (isnan(test_f[i].number.f)) + { + printf("Test failed. Testing isnan(%a) for a %s %s: %d\n\n", test_f[i].number.f, test_f[i].class, test_f[i].type, isnan(test_f[i].number.f)); + break; + } + } + if (i < 4 + 2) + { + test_passed = false; + printf("isnan(x) failed for subnormals aka denormals.\n"); + } + + for (i = 4 + 2; i < 4 + 2 + 2; i++) + { + if (isnan(test_ld[i].number.ld)) + { + printf("Test failed. Testing isnan(%La) for a %s %s: %d\n", test_ld[i].number.ld, test_ld[i].class, test_ld[i].type, isnan(test_ld[i].number.ld)); + break; + } + else if (isnan(test_d[i].number.d)) + { + printf("Test failed. Testing isnan(%a) for a %s %s: %d\n", test_d[i].number.d, test_d[i].class, test_d[i].type, isnan(test_d[i].number.d)); + break; + } + else if (isnan(test_f[i].number.f)) + { + printf("Test failed. Testing isnan(%a) for a %s %s: %d\n\n", test_f[i].number.f, test_f[i].class, test_f[i].type, isnan(test_f[i].number.f)); + break; + } + } + if (i < 4 + 2 + 2) + { + test_passed = false; + printf("isnan(x) failed for zero.\n"); + } + + for (i = 4 + 2 + 2; i < 4 + 2 + 2 + 2; i++) + { + if (isnan(test_ld[i].number.ld)) + { + printf("Test failed. Testing isnan(%La) for a %s %s: %d\n", test_ld[i].number.ld, test_ld[i].class, test_ld[i].type, isnan(test_ld[i].number.ld)); + break; + } + else if (isnan(test_d[i].number.d)) + { + printf("Test failed. Testing isnan(%a) for a %s %s: %d\n", test_d[i].number.d, test_d[i].class, test_d[i].type, isnan(test_d[i].number.d)); + break; + } + else if (isnan(test_f[i].number.f)) + { + printf("Test failed. Testing isnan(%a) for a %s %s: %d\n\n", test_f[i].number.f, test_f[i].class, test_f[i].type, isnan(test_f[i].number.f)); + break; + } + } + if (i < 4 + 2 + 2 + 2) + { + test_passed = false; + printf("isnan(x) failed for infinity.\n"); + } + + for (i = 4 + 2 + 2 + 2; i < 4 + 2 + 2 + 2 + 4; i++) + { + if (!isnan(test_ld[i].number.ld)) + { + printf("Test failed. Testing isnan(%La) for a %s %s: %d\n", test_ld[i].number.ld, test_ld[i].class, test_ld[i].type, isnan(test_ld[i].number.ld)); + break; + } + else if (!isnan(test_d[i].number.d)) + { + printf("Test failed. Testing isnan(%a) for a %s %s: %d\n", test_d[i].number.d, test_d[i].class, test_d[i].type, isnan(test_d[i].number.d)); + break; + } + else if (!isnan(test_f[i].number.f)) + { + printf("Test failed. Testing isnan(%a) for a %s %s: %d\n\n", test_f[i].number.f, test_f[i].class, test_f[i].type, isnan(test_f[i].number.f)); + break; + } + } + if (i < 4 + 2 + 2 + 2 + 4) + { + test_passed = false; + printf("isnan(x) failed for SNaN and/or QNaN.\n"); + } + else if (test_passed) + printf("isnan(x) passed all tests.\n"); + printf("----------------------------------------------------------------------\n"); + + + + /* + * isgreater must return zero if x or y is [SQ]NaN (positive or negative) + * and else the result of x > y. + */ + test_passed = true; + for (i = 0; i < 4; i += 3) + { + if (isgreater(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing isgreater(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, isgreater(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (isgreater(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing isgreater(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, isgreater(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (!isgreater(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing isgreater(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, isgreater(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4) + { + test_passed = false; + printf("isgreater(x, y) failed for normals.\n"); + } + + for (i = 1; i < 4 - 1; i++) + { + if (!isgreater(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing isgreater(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, isgreater(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (!isgreater(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing isgreater(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, isgreater(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (isgreater(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing isgreater(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, isgreater(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4 - 1) + { + test_passed = false; + printf("isgreater(x, y) failed for normals.\n"); + } + + for (i = 4; i < 4 + 1; i++) + { + if (isgreater(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing isgreater(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, isgreater(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (isgreater(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing isgreater(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, isgreater(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (!isgreater(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing isgreater(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, isgreater(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4 + 1) + { + test_passed = false; + printf("isgreater(x, y) failed for subnormals.\n"); + } + + for (i = 4 + 1; i < 4 + 2; i++) + { + if (!isgreater(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing isgreater(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, isgreater(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (!isgreater(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing isgreater(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, isgreater(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (isgreater(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing isgreater(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, isgreater(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4 + 2) + { + test_passed = false; + printf("isgreater(x, y) failed for subnormals.\n"); + } + + for (i = 4 + 2; i < 4 + 2 + 2; i++) + { + if (isgreater(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing isgreater(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, isgreater(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (isgreater(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing isgreater(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, isgreater(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (isgreater(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing isgreater(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, isgreater(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4 + 2 + 2) + { + test_passed = false; + printf("isgreater(x, y) failed for zero.\n"); + } + + for (i = 4 + 2 + 2; i < 4 + 2 + 2 + 2; i++) + { + if (isgreater(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing isgreater(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, isgreater(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (isgreater(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing isgreater(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, isgreater(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (isgreater(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing isgreater(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, isgreater(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4 + 2 + 2 + 2) + { + test_passed = false; + printf("isgreater(x, y) failed for infinity.\n"); + } + + for (i = 4 + 2 + 2 + 2; i < 4 + 2 + 2 + 2 + 4; i++) + { + if (isgreater(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing isgreater(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, isgreater(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (isgreater(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing isgreater(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, isgreater(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (isgreater(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing isgreater(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, isgreater(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4 + 2 + 2 + 2 + 4) + { + test_passed = false; + printf("isgreater(x, y) failed for SNaN and/or QNaN.\n"); + } + else if (test_passed) + printf("isgreater(x, y) passed all tests.\n"); + printf("----------------------------------------------------------------------\n"); + + + + /* + * isgreaterequal must return zero if x or y is [SQ]NaN (positive or negative) + * and else the result of x >= y. + */ + test_passed = true; + for (i = 0; i < 4; i += 3) + { + if (isgreaterequal(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing isgreaterequal(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, isgreaterequal(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (isgreaterequal(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing isgreaterequal(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, isgreaterequal(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (!isgreaterequal(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing isgreaterequal(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, isgreaterequal(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4) + { + test_passed = false; + printf("isgreaterequal(x, y) failed for normals.\n"); + } + + for (i = 1; i < 4 - 1; i++) + { + if (!isgreaterequal(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing isgreaterequal(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, isgreaterequal(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (!isgreaterequal(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing isgreaterequal(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, isgreaterequal(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (isgreaterequal(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing isgreaterequal(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, isgreaterequal(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4 - 1) + { + test_passed = false; + printf("isgreaterequal(x, y) failed for normals.\n"); + } + + for (i = 4; i < 4 + 1; i++) + { + if (isgreaterequal(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing isgreaterequal(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, isgreaterequal(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (isgreaterequal(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing isgreaterequal(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, isgreaterequal(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (!isgreaterequal(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing isgreaterequal(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, isgreaterequal(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4 + 1) + { + test_passed = false; + printf("isgreaterequal(x, y) failed for subnormals.\n"); + } + + for (i = 4 + 1; i < 4 + 2; i++) + { + if (!isgreaterequal(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing isgreaterequal(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, isgreaterequal(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (!isgreaterequal(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing isgreaterequal(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, isgreaterequal(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (isgreaterequal(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing isgreaterequal(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, isgreaterequal(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4 + 2) + { + test_passed = false; + printf("isgreaterequal(x, y) failed for subnormals.\n"); + } + + for (i = 4 + 2; i < 4 + 2 + 2; i++) + { + if (!isgreaterequal(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing isgreaterequal(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, isgreaterequal(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (!isgreaterequal(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing isgreaterequal(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, isgreaterequal(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (!isgreaterequal(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing isgreaterequal(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, isgreaterequal(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4 + 2 + 2) + { + test_passed = false; + printf("isgreaterequal(x, y) failed for zero.\n"); + } + + for (i = 4 + 2 + 2; i < 4 + 2 + 2 + 2; i++) + { + if (!isgreaterequal(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing isgreaterequal(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, isgreaterequal(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (!isgreaterequal(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing isgreaterequal(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, isgreaterequal(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (!isgreaterequal(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing isgreaterequal(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, isgreaterequal(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4 + 2 + 2 + 2) + { + test_passed = false; + printf("isgreaterequal(x, y) failed for infinity.\n"); + } + + for (i = 4 + 2 + 2 + 2; i < 4 + 2 + 2 + 2 + 4; i++) + { + if (isgreaterequal(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing isgreaterequal(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, isgreaterequal(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (isgreaterequal(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing isgreaterequal(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, isgreaterequal(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (isgreaterequal(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing isgreaterequal(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, isgreaterequal(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4 + 2 + 2 + 2 + 4) + { + test_passed = false; + printf("isgreaterequal(x, y) failed for SNaN and/or QNaN.\n"); + } + else if (test_passed) + printf("isgreaterequal(x, y) passed all tests.\n"); + printf("----------------------------------------------------------------------\n"); + + + + /* + * isless must return zero if x or y is [SQ]NaN (positive or negative) + * and else the result of x < y. + */ + test_passed = true; + for (i = 0; i < 4; i += 3) + { + if (!isless(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing isless(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, isless(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (!isless(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing isless(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, isless(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (isless(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing isless(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, isless(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4) + { + test_passed = false; + printf("isless(x, y) failed for normals.\n"); + } + + for (i = 1; i < 4 - 1; i++) + { + if (isless(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing isless(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, isless(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (isless(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing isless(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, isless(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (!isless(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing isless(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, isless(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4 - 1) + { + test_passed = false; + printf("isless(x, y) failed for normals.\n"); + } + + for (i = 4; i < 4 + 1; i++) + { + if (!isless(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing isless(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, isless(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (!isless(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing isless(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, isless(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (isless(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing isless(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, isless(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4 + 1) + { + test_passed = false; + printf("isless(x, y) failed for subnormals.\n"); + } + + for (i = 4 + 1; i < 4 + 2; i++) + { + if (isless(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing isless(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, isless(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (isless(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing isless(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, isless(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (!isless(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing isless(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, isless(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4 + 2) + { + test_passed = false; + printf("isless(x, y) failed for subnormals.\n"); + } + + for (i = 4 + 2; i < 4 + 2 + 2; i++) + { + if (isless(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing isless(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, isless(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (isless(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing isless(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, isless(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (isless(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing isless(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, isless(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4 + 2 + 2) + { + test_passed = false; + printf("isless(x, y) failed for zero.\n"); + } + + for (i = 4 + 2 + 2; i < 4 + 2 + 2 + 2; i++) + { + if (isless(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing isless(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, isless(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (isless(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing isless(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, isless(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (isless(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing isless(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, isless(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4 + 2 + 2 + 2) + { + test_passed = false; + printf("isless(x, y) failed for infinity.\n"); + } + + for (i = 4 + 2 + 2 + 2; i < 4 + 2 + 2 + 2 + 4; i++) + { + if (isless(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing isless(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, isless(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (isless(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing isless(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, isless(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (isless(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing isless(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, isless(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4 + 2 + 2 + 2 + 4) + { + test_passed = false; + printf("isless(x, y) failed for SNaN and/or QNaN.\n"); + } + else if (test_passed) + printf("isless(x, y) passed all tests.\n"); + printf("----------------------------------------------------------------------\n"); + + + + /* + * islessequal must return zero if x or y is [SQ]NaN (positive or negative) + * and else the result of x <= y. + */ + test_passed = true; + for (i = 0; i < 4; i += 3) + { + if (!islessequal(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing islessequal(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, islessequal(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (!islessequal(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing islessequal(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, islessequal(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (islessequal(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing islessequal(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, islessequal(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4) + { + test_passed = false; + printf("islessequal(x, y) failed for normals.\n"); + } + + for (i = 1; i < 4 - 1; i++) + { + if (islessequal(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing islessequal(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, islessequal(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (islessequal(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing islessequal(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, islessequal(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (!islessequal(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing islessequal(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, islessequal(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4 - 1) + { + test_passed = false; + printf("islessequal(x, y) failed for normals.\n"); + } + + for (i = 4; i < 4 + 1; i++) + { + if (!islessequal(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing islessequal(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, islessequal(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (!islessequal(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing islessequal(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, islessequal(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (islessequal(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing islessequal(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, islessequal(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4 + 1) + { + test_passed = false; + printf("islessequal(x, y) failed for subnormals.\n"); + } + + for (i = 4 + 1; i < 4 + 2; i++) + { + if (islessequal(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing islessequal(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, islessequal(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (islessequal(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing islessequal(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, islessequal(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (!islessequal(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing islessequal(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, islessequal(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4 + 2) + { + test_passed = false; + printf("islessequal(x, y) failed for subnormals.\n"); + } + + for (i = 4 + 2; i < 4 + 2 + 2; i++) + { + if (!islessequal(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing islessequal(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, islessequal(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (!islessequal(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing islessequal(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, islessequal(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (!islessequal(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing islessequal(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, islessequal(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4 + 2 + 2) + { + test_passed = false; + printf("islessequal(x, y) failed for zero.\n"); + } + + for (i = 4 + 2 + 2; i < 4 + 2 + 2 + 2; i++) + { + if (!islessequal(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing islessequal(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, islessequal(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (!islessequal(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing islessequal(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, islessequal(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (!islessequal(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing islessequal(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, islessequal(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4 + 2 + 2 + 2) + { + test_passed = false; + printf("islessequal(x, y) failed for infinity.\n"); + } + + for (i = 4 + 2 + 2 + 2; i < 4 + 2 + 2 + 2 + 4; i++) + { + if (islessequal(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing islessequal(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, islessequal(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (islessequal(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing islessequal(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, islessequal(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (islessequal(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing islessequal(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, islessequal(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4 + 2 + 2 + 2 + 4) + { + test_passed = false; + printf("islessequal(x, y) failed for SNaN and/or QNaN.\n"); + } + else if (test_passed) + printf("islessequal(x, y) passed all tests.\n"); + printf("----------------------------------------------------------------------\n"); + + + + /* + * islessgreater must return zero if x or y is [SQ]NaN (positive or negative) + * and else the result of (x < y) || x > y). + */ + test_passed = true; + for (i = 0; i < 4; i++) + { + if (!islessgreater(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing islessgreater(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, islessgreater(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (!islessgreater(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing islessgreater(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, islessgreater(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (!islessgreater(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing islessgreater(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, islessgreater(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4) + { + test_passed = false; + printf("islessgreater(x, y) failed for normals.\n"); + } + + for (i = 4; i < 4 + 2; i++) + { + if (!islessgreater(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing islessgreater(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, islessgreater(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (!islessgreater(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing islessgreater(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, islessgreater(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (!islessgreater(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing islessgreater(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, islessgreater(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4 + 2) + { + test_passed = false; + printf("islessgreater(x, y) failed for subnormals.\n"); + } + + for (i = 4 + 2; i < 4 + 2 + 2; i++) + { + if (islessgreater(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing islessgreater(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, islessgreater(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (islessgreater(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing islessgreater(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, islessgreater(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (islessgreater(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing islessgreater(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, islessgreater(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4 + 2 + 2) + { + test_passed = false; + printf("islessgreater(x, y) failed for zero.\n"); + } + + for (i = 4 + 2 + 2; i < 4 + 2 + 2 + 2; i++) + { + if (islessgreater(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing islessgreater(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, islessgreater(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (islessgreater(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing islessgreater(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, islessgreater(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (islessgreater(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing islessgreater(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, islessgreater(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4 + 2 + 2 + 2) + { + test_passed = false; + printf("islessgreater(x, y) failed for infinity.\n"); + } + + for (i = 4 + 2 + 2 + 2; i < 4 + 2 + 2 + 2 + 4; i++) + { + if (islessgreater(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing islessgreater(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, islessgreater(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (islessgreater(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing islessgreater(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, islessgreater(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (islessgreater(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing islessgreater(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, islessgreater(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4 + 2 + 2 + 2 + 4) + { + test_passed = false; + printf("islessgreater(x, y) failed for SNaN and/or QNaN.\n"); + } + else if (test_passed) + printf("islessgreater(x, y) passed all tests.\n"); + printf("----------------------------------------------------------------------\n"); + + + + /* + * isunordered must return non-zero if x or y is [SQ]NaN (positive or negative) + * and zero else. + */ + test_passed = true; + for (i = 0; i < 4; i++) + { + if (isunordered(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing isunordered(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, isunordered(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (isunordered(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing isunordered(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, isunordered(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (isunordered(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing isunordered(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, isunordered(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4) + { + test_passed = false; + printf("isunordered(x) failed for normals.\n"); + } + + for (i = 4; i < 4 + 2; i++) + { + if (isunordered(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing isunordered(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, isunordered(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (isunordered(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing isunordered(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, isunordered(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (isunordered(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing isunordered(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, isunordered(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4 + 2) + { + test_passed = false; + printf("isunordered(x) failed for subnormals aka denormals.\n"); + } + + for (i = 4 + 2; i < 4 + 2 + 2; i++) + { + if (isunordered(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing isunordered(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, isunordered(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (isunordered(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing isunordered(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, isunordered(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (isunordered(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing isunordered(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, isunordered(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4 + 2 + 2) + { + test_passed = false; + printf("isunordered(x) failed for zero.\n"); + } + + for (i = 4 + 2 + 2; i < 4 + 2 + 2 + 2; i++) + { + if (isunordered(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing isunordered(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, isunordered(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (isunordered(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing isunordered(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, isunordered(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (isunordered(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing isunordered(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, isunordered(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4 + 2 + 2 + 2) + { + test_passed = false; + printf("isunordered(x) failed for infinity.\n"); + } + + for (i = 4 + 2 + 2 + 2; i < 4 + 2 + 2 + 2 + 4; i++) + { + if (!isunordered(test_ld[i].number.ld, test_d[i].number.d)) + { + printf("Test failed. Testing isunordered(%La, %a) for a %s %s and %s %s: %d\n", test_ld[i].number.ld, test_d[i].number.d, test_ld[i].class, test_ld[i].type, test_d[i].class, test_d[i].type, isunordered(test_ld[i].number.ld, test_d[i].number.d)); + break; + } + else if (!isunordered(test_d[i].number.d, test_f[i].number.f)) + { + printf("Test failed. Testing isunordered(%a, %a) for a %s %s and %s %s: %d\n", test_d[i].number.d, test_f[i].number.f, test_d[i].class, test_d[i].type, test_f[i].class, test_f[i].type, isunordered(test_d[i].number.d, test_f[i].number.f)); + break; + } + else if (!isunordered(test_f[i].number.f, test_ld[i].number.ld)) + { + printf("Test failed. Testing isunordered(%a, %La) for a %s %s and %s %s: %d\n\n", test_f[i].number.f, test_ld[i].number.ld, test_f[i].class, test_f[i].type, test_ld[i].class, test_ld[i].type, isunordered(test_f[i].number.f, test_ld[i].number.ld)); + break; + } + } + if (i < 4 + 2 + 2 + 2 + 4) + { + test_passed = false; + printf("isunordered(x, y) failed for SNaN and/or QNaN.\n"); + } + else if (test_passed) + printf("isunordered(x, y) passed all tests.\n"); + printf("----------------------------------------------------------------------\n"); + + return 0; +}