Fix ldbl-128ibm fmodl handling of equal arguments with low part zero (bug 19602).
[glibc.git] / sysdeps / ieee754 / ldbl-128ibm / test-fmodl-ldbl-128ibm.c
blob3717c90abaa1a85cbcbec76a3ced1821634284a6
1 /* Test for ldbl-128ibm fmodl handling of equal values (bug 19602).
2 Copyright (C) 2016 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #include <float.h>
20 #include <math.h>
21 #include <stdio.h>
23 union u
25 long double ld;
26 double d[2];
29 volatile union u p1 = { .d = { DBL_MIN, 0.0 } };
30 volatile union u p2 = { .d = { DBL_MIN, -0.0 } };
31 volatile union u m1 = { .d = { -DBL_MIN, 0.0 } };
32 volatile union u m2 = { .d = { -DBL_MIN, -0.0 } };
34 static int
35 test_fmodl (const char *s, long double x, long double y, long double expected)
37 volatile long double r;
38 r = fmodl (x, y);
39 if (r != expected || copysignl (1.0, r) != copysignl (1.0, expected))
41 printf ("FAIL: fmodl (%s)\n", s);
42 return 1;
44 else
46 printf ("PASS: fmodl (%s)\n", s);
47 return 0;
51 #define TEST_FMODL(a, b, e) test_fmodl (#a ", " #b, a, b, e)
53 static int
54 do_test (void)
56 int result = 0;
57 result |= TEST_FMODL (p1.ld, p1.ld, 0.0L);
58 result |= TEST_FMODL (p1.ld, p2.ld, 0.0L);
59 result |= TEST_FMODL (p1.ld, m1.ld, 0.0L);
60 result |= TEST_FMODL (p1.ld, m2.ld, 0.0L);
61 result |= TEST_FMODL (p2.ld, p1.ld, 0.0L);
62 result |= TEST_FMODL (p2.ld, p2.ld, 0.0L);
63 result |= TEST_FMODL (p2.ld, m1.ld, 0.0L);
64 result |= TEST_FMODL (p2.ld, m2.ld, 0.0L);
65 result |= TEST_FMODL (m1.ld, p1.ld, -0.0L);
66 result |= TEST_FMODL (m1.ld, p2.ld, -0.0L);
67 result |= TEST_FMODL (m1.ld, m1.ld, -0.0L);
68 result |= TEST_FMODL (m1.ld, m2.ld, -0.0L);
69 result |= TEST_FMODL (m2.ld, p1.ld, -0.0L);
70 result |= TEST_FMODL (m2.ld, p2.ld, -0.0L);
71 result |= TEST_FMODL (m2.ld, m1.ld, -0.0L);
72 result |= TEST_FMODL (m2.ld, m2.ld, -0.0L);
73 return result;
76 #define TEST_FUNCTION do_test ()
77 #include "../../../test-skeleton.c"