1/* mpc_out_str -- Output a complex number on a given stream.
2
3Copyright (C) INRIA, 2009
4
5This file is part of the MPC Library.
6
7The MPC Library is free software; you can redistribute it and/or modify
8it under the terms of the GNU Lesser General Public License as published by
9the Free Software Foundation; either version 2.1 of the License, or (at your
10option) any later version.
11
12The MPC Library is distributed in the hope that it will be useful, but
13WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
15License for more details.
16
17You should have received a copy of the GNU Lesser General Public License
18along with the MPC Library; see the file COPYING.LIB.  If not, write to
19the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20MA 02111-1307, USA. */
21
22#include <stdio.h> /* for FILE */
23#include <ctype.h>
24#include "mpc-impl.h"
25
26size_t
27mpc_out_str (FILE *stream, int base, size_t n, mpc_srcptr op, mpc_rnd_t rnd) {
28   size_t size = 3; /* for '(', ' ' and ')' */
29
30   if (stream == NULL)
31      stream = stdout; /* fprintf does not allow NULL as first argument */
32
33   fprintf (stream, "(");
34   size += mpfr_out_str (stream, base, n, MPC_RE(op), MPC_RND_RE(rnd));
35   fprintf (stream, " ");
36   size += mpfr_out_str (stream, base, n, MPC_IM(op), MPC_RND_RE(rnd));
37   fprintf (stream, ")");
38
39   return size;
40}
41