1 /*
2 Copyright (C) 2014 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 "mag.h"
14 #include "arf.h"
15
16 void
mag_fprint(FILE * file,const mag_t x)17 mag_fprint(FILE * file, const mag_t x)
18 {
19 flint_fprintf(file, "(");
20 if (mag_is_zero(x))
21 flint_fprintf(file, "0");
22 else if (mag_is_inf(x))
23 flint_fprintf(file, "inf");
24 else
25 {
26 fmpz_t t;
27 fmpz_init(t);
28 fmpz_sub_ui(t, MAG_EXPREF(x), MAG_BITS);
29 flint_fprintf(file, "%wu * 2^", MAG_MAN(x));
30 fmpz_fprint(file, t);
31 fmpz_clear(t);
32 }
33 flint_fprintf(file, ")");
34 }
35
36 void
mag_fprintd(FILE * file,const mag_t x,slong d)37 mag_fprintd(FILE * file, const mag_t x, slong d)
38 {
39 arf_t t;
40 arf_init(t);
41 arf_set_mag(t, x);
42 arf_fprintd(file, t, d);
43 arf_clear(t);
44 }
45