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

◆ elem_text_out()

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

Definition at line 39 of file aring-qq-flint.cpp.

44{
45 char s[1000];
46 char* str;
47
48 (void) p_parens;
49 bool is_neg = (fmpq_sgn(&a) == -1);
50 bool one = is_pm_one(a);
51
52 size_t size = fmpz_sizeinbase(fmpq_numref(&a), 10) +
53 fmpz_sizeinbase(fmpq_denref(&a), 10) + 3;
54
55 char* allocstr = (size > 1000 ? newarray_atomic(char, size) : s);
56
57 // std::cout << "size = " << size << std::endl;
58 if (!is_neg && p_plus) o << '+';
59 if (one)
60 {
61 if (is_neg) o << '-';
62 if (p_one) o << '1';
63 }
64 else
65 {
66 str = fmpq_get_str(allocstr, 10, &a);
67 o << str;
68 }
69 // std::cout << "output = " << o.str() << std::endl;
70 if (size > 1000) freemem(allocstr);
71}
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().