This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
The implementations of fmax and fmin in newlib/libm/common appear not to conform to section F.9.9.2/3 of the C99 spec. That spec. states: "If just one argument is a NaN, the fmax functions return the other argument (if both arguments are NaNs, the functions return a NaN)." The following patch fixes this. Steve. --- newlib/libm/common/orig-sf_fmax.c 2002-06-07 22:59:56.000000000 +0100 +++ newlib/libm/common/sf_fmax.c 2005-08-08 17:13:08.000000000 +0100 @@ -15,9 +15,9 @@ #endif { if (__fpclassifyf(x) == FP_NAN) - return x; - if (__fpclassifyf(y) == FP_NAN) return y; + if (__fpclassifyf(y) == FP_NAN) + return x; return x > y ? x : y; } --- newlib/libm/common/orig-s_fmax.c 2002-06-07 22:59:56.000000000 +0100 +++ newlib/libm/common/s_fmax.c 2005-08-08 17:07:04.000000000 +0100 @@ -17,9 +17,9 @@ #endif { if (__fpclassifyd(x) == FP_NAN) - return x; - if (__fpclassifyd(y) == FP_NAN) return y; + if (__fpclassifyd(y) == FP_NAN) + return x; return x > y ? x : y; } --- newlib/libm/common/orig-sf_fmin.c 2002-06-07 22:59:56.000000000 +0100 +++ newlib/libm/common/sf_fmin.c 2005-08-08 17:24:57.000000000 +0100 @@ -15,9 +15,9 @@ #endif { if (__fpclassifyf(x) == FP_NAN) - return x; - if (__fpclassifyf(y) == FP_NAN) return y; + if (__fpclassifyf(y) == FP_NAN) + return x; return x < y ? x : y; } --- newlib/libm/common/orig-s_fmin.c 2002-06-07 22:59:56.000000000 +0100 +++ newlib/libm/common/s_fmin.c 2005-08-08 17:07:16.000000000 +0100 @@ -17,9 +17,9 @@ #endif { if (__fpclassifyd(x) == FP_NAN) - return x; - if (__fpclassifyd(y) == FP_NAN) return y; + if (__fpclassifyd(y) == FP_NAN) + return x; return x < y ? x : y; }
Attachment:
fmax.patch
Description: Binary data
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |