X-Git-Url: https://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-round2.c;h=49a0947dce62fdb3ea79c0f7041a72ad1568389f;hb=d5612c714c87555f1059d71d347e20271dced322;hp=b5944a94b2bda5b64c8caac41c89e7d6499a92da;hpb=f2bbde92e487b8446ff201767c430306450220be;p=gnulib.git diff --git a/tests/test-round2.c b/tests/test-round2.c index b5944a94b..49a0947dc 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-2008 Free Software Foundation, Inc. + Copyright (C) 2007-2012 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 @@ -17,6 +17,9 @@ /* Written by Ben Pfaff , 2007. Heavily based on code by Bruno Haible. */ +/* When this test fails on some platform, build it together with the gnulib + module 'fprintf-posix' for optimal debugging output. */ + /* Get the two reference implementations of round under the names round_reference1 and round_reference2. @@ -62,8 +65,10 @@ equal (const char *message, DOUBLE x, DOUBLE y0, DOUBLE y1) return true; else { +#if GNULIB_TEST_FPRINTF_POSIX 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); +#endif return false; } } @@ -92,17 +97,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); }