long_extras.h
#include <flint/long_extras.h>This module collects a few functions on signed words (slong) that complement the unsigned word functions of ulong_extras.h. The prefix z_ stands for a signed integer, as in the GMP conventions.
Properties#
size_t z_sizeinbase(slong n, int b)Returns the number of digits of |n| in base b \ge 2, the sign not counted. For n = 0 it returns 1. Unlike GMP's mpz_sizeinbase, the result is exact for every base.
Checked arithmetic#
int z_add_checked(slong * a, slong b, slong c)int z_mul_checked(slong * a, slong b, slong c)int z_mat22_det_is_negative(slong m11, slong m12, slong m21, slong m22)Returns 1 if the determinant m_{11} m_{22} - m_{12} m_{21} is negative and 0 otherwise. The determinant is computed exactly in two words, so there is no overflow for any inputs.
Random functions#
slong z_randtest(flint_rand_t state)Returns a random value for testing. With probability 1/8 it is one of the special values 0, 1, -1, COEFF_MAX, COEFF_MIN, WORD_MAX and WORD_MIN, chosen uniformly; otherwise it is a nonnegative random value of between 0 and \mathtt{FLINT\_BITS} - 1 bits, produced by n_randbits.
slong z_randtest_not_zero(flint_rand_t state)As z_randtest, but never returns 0.
slong z_randint(flint_rand_t state, ulong limit)Number theory#
int z_kronecker(slong a, slong n)Returns the Kronecker symbol \left(\frac{a}{n}\right) for any a and n, including negative and even n and n = 0 (where the symbol is 1 if a = \pm 1 and 0 otherwise). For odd positive n this is the Jacobi symbol, which n_jacobi also computes.
The FLINT team, “long_extras.h (module overview),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/long_extras/index.html (generated 2026-10-20).
@misc{flint-doc-long-extras-index,
author = {{The FLINT team}},
title = {{long\_extras.h (module overview)}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/long_extras/index.html},
note = {Generated 2026-10-20}
}