X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-round2.c;h=cad256d11c971b0b12e7fecab6b995ad48812706;hb=724c562aa7cbd2c458da76fd5164e6b071ca9bc8;hp=1da0d9f8c5cd6f1fe66609f851bb373771fde56c;hpb=980d2709cea1e46299cb5b4f74f7c7a95d07ef06;p=gnulib.git diff --git a/tests/test-round2.c b/tests/test-round2.c index 1da0d9f8c..cad256d11 100644 --- a/tests/test-round2.c +++ b/tests/test-round2.c @@ -1,5 +1,5 @@ /* Test of rounding to nearest, breaking ties away from zero. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,7 +19,7 @@ /* Get the two reference implementations of round under the names round_reference1 and round_reference2. - + round.c will #include for us. */ #define FLOOR_BASED_ROUND round_reference1 #define FLOOR_FREE_ROUND round_reference2 @@ -37,15 +37,15 @@ #ifdef USE_LONG_DOUBLE # error Long double not supported. #elif ! defined USE_FLOAT -# include "isnan.h" -# define ISNAN isnan +# include "isnand-nolibm.h" +# define ISNAN isnand # define FUNCTION "round" # define DOUBLE_UINT uint64_t # define DOUBLE_BITS 64 # define NUM_HIGHBITS 13 # define NUM_LOWBITS 4 #else /* defined USE_FLOAT */ -# include "isnanf.h" +# include "isnanf-nolibm.h" # define ISNAN isnanf # define FUNCTION "roundf" # define DOUBLE_UINT uint32_t @@ -60,10 +60,10 @@ equal (const char *message, DOUBLE x, DOUBLE y0, DOUBLE y1) { if (ISNAN (y0) ? ISNAN (y1) : y0 == y1) return true; - else + else { fprintf (stderr, "%s: "FUNCTION"(%g(%a)) = %g(%a) or %g(%a)?\n", - message, x, x, y0, y0, y1, y1); + message, x, x, y0, y0, y1, y1); return false; } } @@ -74,10 +74,10 @@ check (DOUBLE x) { DOUBLE ref1 = round_reference1 (x); DOUBLE ref2 = round_reference2 (x); - DOUBLE result = round (x); - + DOUBLE result = ROUND (x); + /* If the reference implementations disagree, bail out immediately. */ - if (!equal ("reference implementations disagree", x, ref1, ref2)) + if (!equal ("reference implementations disagree", x, ref1, ref2)) exit (EXIT_FAILURE); /* If the actual implementation is wrong, return an error code. */ @@ -92,17 +92,17 @@ main (void) for (highbits = 0; highbits < (1 << NUM_HIGHBITS); highbits++) for (lowbits = 0; lowbits < (1 << NUM_LOWBITS); lowbits++) { - /* Combine highbits and lowbits into a floating-point number, - sign-extending the lowbits to DOUBLE_BITS-NUM_HIGHBITS bits. */ - union { DOUBLE f; DOUBLE_UINT i; } janus; - verify (sizeof janus.f == sizeof janus.i); - janus.i = lowbits | (highbits << (DOUBLE_BITS - NUM_HIGHBITS)); - if (lowbits >> (NUM_LOWBITS - 1)) - janus.i |= ((DOUBLE_UINT) -1 - >> (NUM_LOWBITS + NUM_HIGHBITS) - << NUM_LOWBITS); - if (!check (janus.f)) - error = true; + /* Combine highbits and lowbits into a floating-point number, + sign-extending the lowbits to DOUBLE_BITS-NUM_HIGHBITS bits. */ + union { DOUBLE f; DOUBLE_UINT i; } janus; + verify (sizeof janus.f == sizeof janus.i); + janus.i = lowbits | (highbits << (DOUBLE_BITS - NUM_HIGHBITS)); + if (lowbits >> (NUM_LOWBITS - 1)) + janus.i |= ((DOUBLE_UINT) -1 + >> (NUM_LOWBITS + NUM_HIGHBITS) + << NUM_LOWBITS); + if (!check (janus.f)) + error = true; } return (error ? 1 : 0); }