Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

563680 views
1
/* operator<< -- mpf formatted output to an ostream.
2
3
Copyright 2001, 2002 Free Software Foundation, Inc.
4
5
This file is part of the GNU MP Library.
6
7
The GNU MP Library is free software; you can redistribute it and/or modify
8
it under the terms of the GNU Lesser General Public License as published by
9
the Free Software Foundation; either version 2.1 of the License, or (at your
10
option) any later version.
11
12
The GNU MP Library is distributed in the hope that it will be useful, but
13
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15
License for more details.
16
17
You should have received a copy of the GNU Lesser General Public License
18
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
19
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
MA 02110-1301, USA. */
21
22
#include <clocale>
23
#include <iostream>
24
#include <stdarg.h> /* for va_list and hence doprnt_funs_t */
25
#include <string.h>
26
27
#include "gmp.h"
28
#include "gmp-impl.h"
29
30
using namespace std;
31
32
33
/* The gmp_asprintf support routines never give an error, so
34
__gmp_doprnt_mpf shouldn't fail and it's return can just be checked with
35
an ASSERT. */
36
37
ostream&
38
operator<< (ostream &o, mpf_srcptr f)
39
{
40
struct doprnt_params_t param;
41
struct gmp_asprintf_t d;
42
char *result;
43
int ret;
44
45
__gmp_doprnt_params_from_ios (&param, o);
46
47
#if HAVE_STD__LOCALE
48
char point[2];
49
point[0] = use_facet< numpunct<char> >(o.getloc()).decimal_point();
50
point[1] = '\0';
51
#else
52
const char *point = localeconv()->decimal_point;
53
#endif
54
55
GMP_ASPRINTF_T_INIT (d, &result);
56
ret = __gmp_doprnt_mpf (&__gmp_asprintf_funs_noformat, &d, &param, point, f);
57
ASSERT (ret != -1);
58
__gmp_asprintf_final (&d);
59
60
gmp_allocated_string t (result);
61
return o.write (t.str, t.len);
62
}
63
64