1 /* Test file for mpfr_cmp_ld.
3 Copyright 2004, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
4 Contributed by the AriC and Caramel projects, INRIA.
6 This file is part of the GNU MPFR Library.
8 The GNU MPFR Library is free software; you can redistribute it and/or modify
9 it under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or (at your
11 option) any later version.
13 The GNU MPFR Library is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16 License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with the GNU MPFR Library; see the file COPYING.LESSER. If not, see
20 http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
21 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
25 #include "mpfr-test.h"
35 mpfr_init2(x, MPFR_LDBL_MANT_DIG);
37 mpfr_set_ld (x, 2.34763465L, MPFR_RNDN);
38 if (mpfr_cmp_ld(x, 2.34763465L)!=0) {
39 printf("Error in mpfr_cmp_ld 2.34763465 and ");
40 mpfr_out_str(stdout, 10, 0, x, MPFR_RNDN); putchar('\n');
43 if (mpfr_cmp_ld(x, 2.345L)<=0) {
44 printf("Error in mpfr_cmp_ld 2.345 and ");
45 mpfr_out_str(stdout, 10, 0, x, MPFR_RNDN); putchar('\n');
48 if (mpfr_cmp_ld(x, 2.4L)>=0) {
49 printf("Error in mpfr_cmp_ld 2.4 and ");
50 mpfr_out_str(stdout, 10, 0, x, MPFR_RNDN); putchar('\n');
54 mpfr_set_ui (x, 0, MPFR_RNDZ);
55 mpfr_neg (x, x, MPFR_RNDZ);
56 if (mpfr_cmp_ld (x, 0.0)) {
57 printf("Error in mpfr_cmp_ld 0.0 and ");
58 mpfr_out_str(stdout, 10, 0, x, MPFR_RNDN); putchar('\n');
62 mpfr_set_ui (x, 0, MPFR_RNDN);
63 mpfr_ui_div (x, 1, x, MPFR_RNDU);
64 if (mpfr_cmp_ld (x, 0.0) == 0)
66 printf ("Error in mpfr_cmp_ld (Inf, 0)\n");
70 #if !defined(MPFR_ERRDIVZERO)
72 mpfr_clear_erangeflag ();
73 c = mpfr_cmp_ld (x, DBL_NAN);
74 if (c != 0 || !mpfr_erangeflag_p ())
76 printf ("ERROR for NAN (1)\n");
78 printf ("The reason is that NAN == NAN. Please look at the configure "
79 "output\nand Section \"In case of problem\" of the INSTALL "
85 mpfr_clear_erangeflag ();
86 c = mpfr_cmp_ld (x, 2.0);
87 if (c != 0 || !mpfr_erangeflag_p ())
89 printf ("ERROR for NAN (2)\n");
91 printf ("The reason is that NAN == NAN. Please look at the configure "
92 "output\nand Section \"In case of problem\" of the INSTALL "
97 #endif /* MPFR_ERRDIVZERO */