1 /* tnorm -- test file for mpc_norm.
3 Copyright (C) 2008, 2011 INRIA
5 This file is part of GNU MPC.
7 GNU MPC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU Lesser General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
12 GNU MPC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
17 You should have received a copy of the GNU Lesser General Public License
18 along with this program. If not, see http://www.gnu.org/licenses/ .
21 #include "mpc-tests.h"
26 mpfr_exp_t emin = mpfr_get_emin ();
31 mpfr_set_emin (-1); /* smallest positive number is 0.5*2^emin = 0.25 */
33 mpfr_set_ui_2exp (mpc_realref (z), 1023, -11, GMP_RNDN); /* exact */
34 mpfr_set_ui_2exp (mpc_imagref (z), 1023, -11, GMP_RNDN); /* exact */
37 inex = mpc_norm (f, z, GMP_RNDZ); /* should give 511/1024 */
40 printf ("Error in underflow case (1)\n");
41 printf ("expected inex < 0, got %d\n", inex);
44 if (mpfr_cmp_ui_2exp (f, 511, -10) != 0)
46 printf ("Error in underflow case (1)\n");
50 mpfr_set_ui_2exp (f, 511, -10, GMP_RNDZ);
55 inex = mpc_norm (f, z, GMP_RNDN); /* should give 511/1024 */
58 printf ("Error in underflow case (2)\n");
59 printf ("expected inex < 0, got %d\n", inex);
62 if (mpfr_cmp_ui_2exp (f, 511, -10) != 0)
64 printf ("Error in underflow case (2)\n");
68 mpfr_set_ui_2exp (f, 511, -10, GMP_RNDZ);
73 inex = mpc_norm (f, z, GMP_RNDU); /* should give 1023/2048 */
76 printf ("Error in underflow case (3)\n");
77 printf ("expected inex > 0, got %d\n", inex);
80 if (mpfr_cmp_ui_2exp (f, 1023, -11) != 0)
82 printf ("Error in underflow case (3)\n");
86 mpfr_set_ui_2exp (f, 1023, -11, GMP_RNDZ);
99 DECL_FUNC (FC, f, mpc_norm);
103 data_check (f, "norm.dat");
104 tgeneric (f, 2, 1024, 1, 4096);