mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-06 04:00:25 +08:00
Add minus zero test
From-SVN: r20152
This commit is contained in:
parent
726e2d544c
commit
655ccec163
@ -1,3 +1,7 @@
|
||||
Sun May 31 23:23:29 1998 Michael Meissner <meissner@cygnus.com>
|
||||
|
||||
* execute/ieee/mzero2.c: New test to better test IEEE -0 support.
|
||||
|
||||
Wed Apr 8 13:09:15 1998 Jim Wilson <wilson@cygnus.com>
|
||||
|
||||
* execute/980407-1.c: Delete test. Is duplicate of loop-4.c.
|
||||
|
58
gcc/testsuite/gcc.c-torture/execute/ieee/mzero2.c
Normal file
58
gcc/testsuite/gcc.c-torture/execute/ieee/mzero2.c
Normal file
@ -0,0 +1,58 @@
|
||||
/* Test IEEE +0/-0 rules */
|
||||
|
||||
static double pzero = +0.0;
|
||||
static double nzero = -0.0;
|
||||
static double pinf = +1.0 / 0.0;
|
||||
static double ninf = -1.0 / 0.0;
|
||||
static double nan = 0.0 / 0.0;
|
||||
|
||||
void
|
||||
expect (double value, double expected)
|
||||
{
|
||||
if (expected != expected) /* expected value is Not a number */
|
||||
{
|
||||
if (value == value) /* actual value is a number */
|
||||
abort ();
|
||||
}
|
||||
|
||||
else if (value != value)
|
||||
abort (); /* actual value is a NaN */
|
||||
|
||||
else if (memcmp ((void *)&value, (void *)&expected, sizeof (double)) != 0)
|
||||
abort (); /* values don't match */
|
||||
}
|
||||
|
||||
main ()
|
||||
{
|
||||
expect (pzero + pzero, pzero);
|
||||
expect (pzero + nzero, pzero);
|
||||
expect (nzero + pzero, pzero);
|
||||
expect (nzero + nzero, nzero);
|
||||
|
||||
expect (pzero - pzero, pzero);
|
||||
expect (pzero - nzero, pzero);
|
||||
expect (nzero - pzero, nzero);
|
||||
expect (nzero - nzero, pzero);
|
||||
|
||||
expect (pzero * pzero, pzero);
|
||||
expect (pzero * nzero, nzero);
|
||||
expect (nzero * pzero, nzero);
|
||||
expect (nzero * nzero, pzero);
|
||||
|
||||
expect (+1.00 * pzero, pzero);
|
||||
expect (-1.00 * pzero, nzero);
|
||||
expect (+1.00 * nzero, nzero);
|
||||
expect (-1.00 * nzero, pzero);
|
||||
|
||||
expect (pzero / pzero, nan);
|
||||
expect (pzero / nzero, nan);
|
||||
expect (nzero / pzero, nan);
|
||||
expect (nzero / nzero, nan);
|
||||
|
||||
expect (+1.00 / pzero, pinf);
|
||||
expect (-1.00 / pzero, ninf);
|
||||
expect (+1.00 / nzero, ninf);
|
||||
expect (-1.00 / nzero, pinf);
|
||||
|
||||
exit (0);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user