Macaulay2 Engine
Loading...
Searching...
No Matches

◆ elem_text_out()

void M2::ARingQQGMP::elem_text_out ( buffer & o,
const ElementType & a,
bool p_one = true,
bool p_plus = false,
bool p_parens = false ) const

Definition at line 32 of file aring-qq-gmp.cpp.

37{
38 char s[1000];
39 char* str;
40
41 (void) p_parens;
42 bool is_neg = (mpq_sgn(&a) == -1);
43 bool one = is_pm_one(a);
44
45 size_t size = mpz_sizeinbase(mpq_numref(&a), 10) +
46 mpz_sizeinbase(mpq_denref(&a), 10) + 3;
47
48 char* allocstr = (size > 1000 ? newarray_atomic(char, size) : s);
49
50 if (!is_neg && p_plus) o << '+';
51 if (one)
52 {
53 if (is_neg) o << '-';
54 if (p_one) o << '1';
55 }
56 else
57 {
58 str = mpq_get_str(allocstr, 10, &a);
59 o << str;
60 }
61 if (size > 1000) freemem(allocstr);
62}
bool is_pm_one(const ElementType &f) const
void freemem(void *s)
Definition m2-mem.cpp:103
void size_t s
Definition m2-mem.cpp:271
#define newarray_atomic(T, len)
Definition newdelete.hpp:91

References freemem(), is_pm_one(), newarray_atomic, and s.

Referenced by TEST().