FLINT3.7.0-dev

ca_get_fmpz, ca_get_fmpq, ca_get_qqbar

Synopsis#include <flint/ca.h>
int ca_get_fmpz(fmpz_t res, const ca_t x, ca_ctx_t ctx)source
int ca_get_fmpq(fmpq_t res, const ca_t x, ca_ctx_t ctx)source
int ca_get_qqbar(qqbar_t res, const ca_t x, ca_ctx_t ctx)source

Attempts to evaluate x to an explicit integer, rational number or algebraic number. On success, sets res to this number and returns 1; otherwise returns 0 and leaves res unspecified.

The conversion fails if x is a special value or is not an integer, rational or algebraic number, but it can also fail when x is one. An element of a field with one algebraic generator is always converted. In other fields, the extension numbers must themselves be evaluable to algebraic numbers (see ca_can_evaluate_qqbar); the numerator and denominator are then evaluated with qqbar.h arithmetic, which is aborted when an intermediate result, or more precisely a resultant before factorisation, has degree larger than CA_OPT_QQBAR_DEG_LIMIT or coefficients larger than about 10 \cdot CA_OPT_PREC_LIMIT bits. These limits can be reached even if the minimal polynomial of x is small.

Guides#

Cite this page

The FLINT team, “ca_get_fmpz, ca_get_fmpq, ca_get_qqbar (ca.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/ca/ca_get_fmpz.html (generated 2026-10-20).