1 /* tui_div -- test file for mpc_ui_div.
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"
31 mpc_set_ui_ui (a, 2, 4, MPC_RNDNN);
32 mpc_ui_div (b, 10, a, MPC_RNDNN);
33 if (mpc_cmp_si_si (b, 1, -2) != 0)
35 printf ("10/(2,4) failed\n");
36 printf ("expected (1,-2)\n");
38 mpc_out_str (stdout, 10, 0, b, MPC_RNDNN);
43 /* 0/(-1-0*I) should give (-0, +0) */
44 mpfr_set_str (mpc_realref(a), "-1", 10, GMP_RNDN);
45 mpfr_set_str (mpc_imagref(a), "-0", 10, GMP_RNDN);
46 mpc_ui_div (b, 0, a, MPC_RNDNN);
47 if ((mpc_cmp_si_si (b, 0, 0) != 0) || (MPFR_SIGN (mpc_realref(b)) > 0)
48 || (MPFR_SIGN (mpc_imagref(b)) < 0))
50 printf ("0/(-1,-0) failed\n");
51 printf ("expected (-0,+0)\n");
53 mpc_out_str (stdout, 10, 0, b, MPC_RNDNN);
58 mpc_set_ui_ui (a, 1, 0, MPC_RNDNN);
59 mpc_ui_div (b, 1, a, MPC_RNDNN);
60 if (mpc_cmp_si_si (b, 1, 0) != 0)
62 printf ("1/(1,0) failed\n");
63 printf ("expected (1,0)\n");
65 mpc_out_str (stdout, 10, 0, b, MPC_RNDNN);
70 /* problem reported by Timo Hartmann with mpc-0.7, 21 Oct 2009 */
71 mpc_set_ui_ui (a, 4, 0, MPC_RNDNN);
72 mpc_ui_div (b, 1, a, MPC_RNDNN);
73 if (mpfr_cmp_ui_2exp (mpc_realref(b), 1, -2) != 0 ||
74 mpfr_cmp_ui (mpc_imagref(b), 0) != 0 || mpfr_signbit (mpc_imagref(b)) != 0)
76 printf ("1/(4,0) failed\n");
77 printf ("expected (1/4,0)\n");
79 mpc_out_str (stdout, 10, 0, b, MPC_RNDNN);
91 DECL_FUNC (CUC, f, mpc_ui_div);
97 tgeneric (f, 2, 1024, 7, 4096);