FLINT3.7.0-dev

fmpq_randtest, _fmpq_randtest

Synopsis#include <flint/fmpq.h>
void fmpq_randtest(fmpq_t res, flint_rand_t state, flint_bitcnt_t bits)source
void _fmpq_randtest(fmpz_t num, fmpz_t den, flint_rand_t state, flint_bitcnt_t bits)source

Set the result to a random canonical fraction whose numerator and denominator have at most bits bits. The distribution favours special values (\pm 1, \pm 2, denominators 1 and 2, values with long runs of bits) that trigger corner cases. For bits equal to 1 the result is an integer. num and den must not be aliased.

Cite this page

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