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

563641 views
1
/* __gmp_doprnt_integer_ios -- integer formatted output to an ostream.
2
3
THE FUNCTIONS IN THIS FILE ARE FOR INTERNAL USE ONLY. THEY'RE ALMOST
4
CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN
5
FUTURE GNU MP RELEASES.
6
7
Copyright 2001 Free Software Foundation, Inc.
8
9
This file is part of the GNU MP Library.
10
11
The GNU MP Library is free software; you can redistribute it and/or modify
12
it under the terms of the GNU Lesser General Public License as published by
13
the Free Software Foundation; either version 2.1 of the License, or (at your
14
option) any later version.
15
16
The GNU MP Library is distributed in the hope that it will be useful, but
17
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
19
License for more details.
20
21
You should have received a copy of the GNU Lesser General Public License
22
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
23
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
24
MA 02110-1301, USA. */
25
26
#include <iostream>
27
#include <cstdarg> /* for va_list and hence doprnt_funs_t */
28
#include <cstring> /* for strlen */
29
30
#include "gmp.h"
31
#include "gmp-impl.h"
32
33
using namespace std;
34
35
36
/* The gmp_asprintf support routines never give an error, so
37
__gmp_doprnt_integer shouldn't fail and it's return can just be checked
38
with an ASSERT. */
39
40
ostream&
41
__gmp_doprnt_integer_ostream (ostream &o, struct doprnt_params_t *p,
42
char *s)
43
{
44
struct gmp_asprintf_t d;
45
char *result;
46
int ret;
47
48
/* don't show leading zeros the way printf does */
49
p->prec = -1;
50
51
GMP_ASPRINTF_T_INIT (d, &result);
52
ret = __gmp_doprnt_integer (&__gmp_asprintf_funs_noformat, &d, p, s);
53
ASSERT (ret != -1);
54
__gmp_asprintf_final (&d);
55
(*__gmp_free_func) (s, strlen(s)+1);
56
57
gmp_allocated_string t (result);
58
return o.write (t.str, t.len);
59
}
60
61