FLINT3.7.0-dev

fmpq_set_str

Synopsis#include <flint/fmpq.h>
int fmpq_set_str(fmpq_t dest, const char * s, int base)source

Sets dest to the integer or fraction "p" or "p/q" in the string s, written in base base as accepted by mpq_set_str. Returns 0 on success and -1 if the string is not valid, in which case dest is not changed.

Like mpq_set_str, this function does not canonicalise: "2/4" gives the non-canonical 2/4, and "1/0" is accepted. Call fmpq_canonicalise afterwards if the input may not be in lowest terms.

Guides#

Cite this page

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