1 /*
2     Copyright (C) 2015 Fredrik Johansson
3     Copyright (C) 2015 Arb authors
4 
5     This file is part of Arb.
6 
7     Arb is free software: you can redistribute it and/or modify it under
8     the terms of the GNU Lesser General Public License (LGPL) as published
9     by the Free Software Foundation; either version 2.1 of the License, or
10     (at your option) any later version.  See <http://www.gnu.org/licenses/>.
11 */
12 
13 #include "acb.h"
14 
15 void
acb_fprintn(FILE * file,const acb_t z,slong digits,ulong flags)16 acb_fprintn(FILE * file, const acb_t z, slong digits, ulong flags)
17 {
18     if (arb_is_zero(acb_imagref(z)))
19     {
20         arb_fprintn(file, acb_realref(z), digits, flags);
21     }
22     else if (arb_is_zero(acb_realref(z)))
23     {
24         arb_fprintn(file, acb_imagref(z), digits, flags);
25         flint_fprintf(file, "*I");
26     }
27     else
28     {
29         arb_fprintn(file, acb_realref(z), digits, flags);
30 
31         if ((arb_is_exact(acb_imagref(z)) || (flags & ARB_STR_NO_RADIUS))
32                 && arf_sgn(arb_midref(acb_imagref(z))) < 0)
33         {
34             arb_t t;
35             arb_init(t);
36             arb_neg(t, acb_imagref(z));
37             flint_fprintf(file, " - ");
38             arb_fprintn(file, t, digits, flags);
39             arb_clear(t);
40         }
41         else
42         {
43             flint_fprintf(file, " + ");
44             arb_fprintn(file, acb_imagref(z), digits, flags);
45         }
46 
47         flint_fprintf(file, "*I");
48     }
49 }
50 
51