Structs

Constants

Statics

Functions

  • Returns a pointer to a brief, human-readable, zero-terminated string describing res. The returned string is statically allocated and must not be freed by the caller.
  • Sets c to the absolute value of a.
  • Sets c to the sum of a and b.
  • Sets c to the sum of a and value.
  • Allocates a fresh zero-valued mpz_t on the heap, returning NULL in case of error. The only possible error is out-of-memory.
  • Returns the number of bytes to represent z in 2’s complement binary.
  • Releases the storage used by z.
  • Returns the comparator of a and b.
  • Returns the comparator of the magnitudes of a and b, disregarding their signs. Neither a nor b is modified by the comparison.
  • Returns the comparator of z and the unsigned value uv.
  • Returns the comparator of z and the signed value v.
  • Returns the comparator of z and zero.
  • Replaces the value of c with a copy of the value of a. No new memory is allocated unless a has more significant digits than c has allocated.
  • Returns the number of significant bits in z.
  • Sets the default number of digits allocated to an mp_int constructed by mp_int_init_size() with prec == 0. Allocations are rounded up to multiples of this value. MP_DEFAULT_PREC is the default value. Requires ndigits > 0.
  • Sets q and r to the quotent and remainder of a / b. Division by powers of 2 is detected and handled efficiently. The remainder is pinned to 0 <= r < b.
  • Sets q and r to the quotient and remainder of a / 2^p2. This is a special case for division by powers of two that is more efficient than using ordinary division. Note that mp_int_div() will automatically handle this case, this function is for cases where you have only the exponent.
  • Sets q and *r to the quotent and remainder of a / value. Division by powers of 2 is detected and handled efficiently. The remainder is pinned to 0 <= *r < b. Either of q or r may be NULL.
  • Reports whether a is divisible by v.
  • Sets c to the greatest common divisor of a and b, and sets x and y to values satisfying Bezout’s identity gcd(a, b) = ax + by.
  • Sets c to the value of a raised to the b power. It returns MP_RANGE if b < 0.
  • Sets c to the value of a raised to the b power. It returns MP_RANGE) if b < 0.
  • Sets c to the value of a raised to the b power. It returns MP_RANGE if b < 0.
  • Sets c to the value of a raised to the b power, reduced modulo m. It returns MP_RANGE if b < 0 or MP_UNDEF if m == 0.
  • Sets c to the value of value raised to the b power, modulo m. It returns MP_RANGE if b < 0 or MP_UNDEF if m == 0.
  • Sets c to the value of a raised to the value power, modulo m. It returns MP_RANGE if value < 0 or MP_UNDEF if m == 0.
  • Sets c to the value of a raised to the b power, reduced modulo m, given a precomputed reduction constant mu defined for Barrett’s modular reduction algorithm.
  • Releases the storage used by z and also z itself. This should only be used for z allocated by mp_int_alloc().
  • Sets c to the greatest common divisor of a and b.
  • Initializes z with 1-digit precision and sets it to zero. This function cannot fail unless z == NULL.
  • Initializes z to be a copy of an already-initialized value in old. The new copy does not share storage with the original.
  • Initializes z with at least prec digits of storage, and sets it to zero. If prec is zero, the default precision is used. In either case the size is rounded up to the nearest multiple of the word size.
  • Initializes z to the specified unsigned value at default precision.
  • Initializes z to the specified signed value at default precision.
  • Sets c to the multiplicative inverse of a modulo m, if it exists. The least non-negative representative of the congruence class is computed.
  • Returns k >= 0 such that z is 2^k, if such a k exists. If no such k exists, the function returns -1.
  • Sets c to the least common multiple of a and b.
  • Sets c to the remainder of a / m. The remainder is pinned to 0 <= c < m.
  • Sets c to the product of a and b.
  • Sets c to the product of a and 2^p2. Requires p2 >= 0.
  • Sets c to the product of a and value.
  • Sets the number of digits below which multiplication will use the standard quadratic “schoolbook” multiplication algorithm rather than Karatsuba-Ofman. Requires ndigits >= sizeof(mp_word).
  • Sets c to the additive inverse (negation) of a.
  • Reads a 2’s complement binary value from buf into z, where len is the length of the buffer. The contents of buf may be overwritten during processing, although they will be restored when the function returns.
  • Reads a string of ASCII digits in the specified radix from the zero terminated str provided into z. For values of radix > 10, the letters A..Z or a..z are accepted. Letters are interpreted without respect to case.
  • Reads a string of ASCII digits in the specified radix from the zero terminated str provided into z. For values of radix > 10, the letters A..Z or a..z are accepted. Letters are interpreted without respect to case.
  • Reads an unsigned binary value from buf into z, where len is the length of the buffer. The contents of buf are not modified during processing.
  • Sets c to the reduction constant for Barrett reduction by modulus m. Requires that c and m point to distinct locations.
  • Sets c to the greatest integer not less than the bth root of a, using Newton’s root-finding algorithm. It returns MP_UNDEF if a < 0 and b is even.
  • Sets z to the value of the specified unsigned value.
  • Sets z to the value of the specified signed value.
  • Sets c to the square of a.
  • Reports the minimum number of characters required to represent z as a zero-terminated string in the given radix. Requires MP_MIN_RADIX <= radix <= MP_MAX_RADIX.
  • Sets c to the difference of a less b.
  • Sets c to the difference of a less value.
  • Swaps the values and storage between a and c.
  • Converts z to 2’s complement binary, writing at most limit bytes into the given buf. Returns MP_TRUNC if the buffer limit was too small to contain the whole value. If this occurs, the contents of buf will be effectively garbage, as the function uses the buffer as scratch space.
  • Returns MP_OK if z is representable as mp_small, else MP_RANGE. If out is not NULL, *out is set to the value of z when MP_OK.
  • Converts z to a zero-terminated string of characters in the specified radix, writing at most limit characters to str including the terminating NUL value. A leading - is used to indicate a negative value.
  • Returns MP_OK if z is representable as mp_usmall, or MP_RANGE. If out is not NULL, *out is set to the value of z when MP_OK.
  • Converts the magnitude of z to unsigned binary, writing at most limit bytes into the given buf. The sign of z is ignored, but z is not modified. Returns MP_TRUNC if the buffer limit was too small to contain the whole value. If this occurs, the contents of buf will be effectively garbage, as the function uses the buffer as scratch space during conversion.
  • Returns the number of bytes required to represent z as an unsigned binary value in base 256.
  • Sets z to zero. The allocated storage of z is not changed.
  • Sets c to the absolute value of a.
  • Sets c to the sum of a and b.
  • Sets c to the sum of a and integer b.
  • Allocates a fresh zero-valued mpq_t on the heap, returning NULL in case of error. The only possible error is out-of-memory.
  • Releases the storage used by r.
  • Returns the comparator of a and b.
  • Returns the comparator of the magnitudes of a and b, disregarding their signs. Neither a nor b is modified by the comparison.
  • Returns the comparator of r and the signed ratio n / d. It returns MP_UNDEF if d is zero.
  • Returns the comparator of r and zero.
  • Sets c to a copy of the value of a. No new memory is allocated unless a term of a has more significant digits than the corresponding term of c has allocated.
  • Reports the length in bytes of the buffer needed to convert r using the mp_rat_to_decimal() function with the specified radix and prec. The buffer size estimate may slightly exceed the actual required capacity.
  • Sets z to a copy of the denominator of r.
  • Returns a pointer to the denominator of r.
  • Sets c to the ratio a / b if that ratio is defined. It returns MP_UNDEF if b is zero.
  • Sets c to the ratio a / b if that ratio is defined. It returns MP_UNDEF if b is zero.
  • Sets c to the value of a raised to the b power. It returns MP_RANGE if b < 0.
  • Releases the storage used by r and also r itself. This should only be used for r allocated by mp_rat_alloc().
  • Initializes r with 1-digit precision and sets it to zero. This function cannot fail unless r is NULL.
  • Initializes r to be a copy of an already-initialized value in old. The new copy does not share storage with the original.
  • Initializes r with at least n_prec digits of storage for the numerator and d_prec digits of storage for the denominator, and value zero.
  • Reports whether r is an integer, having canonical denominator 1.
  • Sets c to the product of a and b.
  • Sets c to the product of a and integer b.
  • Sets c to the absolute value of a.
  • Sets z to a copy of the numerator of r.
  • Returns a pointer to the numerator of r.
  • Sets r to the value represented by a zero-terminated string str in the format "z.ffff" including a sign flag. It returns MP_UNDEF if the effective denominator. If end is not NULL then *end is set to point to the first unconsumed character in the string, after parsing.
  • Sets r to the value represented by a zero-terminated string str in the format "n/d" including a sign flag. It returns MP_UNDEF if the encoded denominator has value zero. If end is not NULL then *end is set to point to the first unconsumed character in the string, after parsing.
  • Sets r to the value represented by a zero-terminated string str in the format "z.ffff" including a sign flag. It returns MP_UNDEF if the effective denominator.
  • Sets r to the value represented by a zero-terminated string str in the format "n/d" including a sign flag. It returns MP_UNDEF if the encoded denominator has value zero.
  • Sets r to the value represented by a zero-terminated string str having one of the following formats, each with an optional leading sign flag:
  • Sets c to the reciprocal of a if the reciprocal is defined. It returns MP_UNDEF if a is zero.
  • Reduces r in-place to lowest terms and canonical form.
  • Sets the value of r to the ratio of unsigned numer to unsigned denom. It returns MP_UNDEF if denom is zero.
  • Sets the value of r to the ratio of signed numer to signed denom. It returns MP_UNDEF if denom is zero.
  • Reports the sign of r.
  • Reports the minimum number of characters required to represent r as a zero-terminated string in the given radix. Requires MP_MIN_RADIX <= radix <= MP_MAX_RADIX.
  • Sets c to the difference of a less b.
  • Sets c to the difference of a less integer b.
  • Converts the value of r to a string in decimal-point notation with the specified radix, writing no more than limit bytes of data to the given output buffer. It generates prec digits of precision, and requires MP_MIN_RADIX <= radix <= MP_MAX_RADIX.
  • Reports whether the numerator and denominator of r can be represented as small signed integers, and if so stores the corresponding values to num and den. It returns MP_RANGE if either cannot be so represented.
  • Converts r to a zero-terminated string of the format "n/d" with n and d in the specified radix and writing no more than limit bytes to the given output buffer str. The output of the numerator includes a sign flag if r is negative. Requires MP_MIN_RADIX <= radix <= MP_MAX_RADIX.
  • Sets r to zero. The allocated storage of r is not changed.

Type Aliases