void renf_elem_class::assign(const mpq_class & value) noexcept { if (nf == nullptr) fmpq_set_mpq(b, value.__get_mp()); else renf_elem_set_mpq(a, value.get_mpq_t(), nf->renf_t()); }
bool _Format_o(Signal &sig, Formatter *pFormatter, const Formatter::Flags &flags, const mpq_class &num) { char *str = nullptr; ::gmp_asprintf(&str, Formatter::ComposeFlags(flags, "Qo").c_str(), num.get_mpq_t()); bool rtn = pFormatter->PutString(sig, str); ::free(str); return rtn; }
/** * Helper function to convert an mpq_class object into * its internal QString representation. Mainly used for * debugging. */ static QString mpqToString(const mpq_class & val) { char *p = 0; // use the gmp provided conversion routine gmp_asprintf(&p, "%Qd", val.get_mpq_t()); // convert it into a QString QString result = QString::fromLatin1(p); // and free up the resources allocated by gmp_asprintf __gmp_freefunc_t freefunc; mp_get_memory_functions(NULL, NULL, &freefunc); (*freefunc)(p, std::strlen(p) + 1); if (!result.contains(QLatin1Char('/'))) { result += QString::fromLatin1("/1"); } // done return result; }
QDebug operator<<(QDebug s, const mpq_class& m) { char b[65536] = ""; gmp_sprintf (b, "%Qd", m.get_mpq_t()); s << b; return s; }