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 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.
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.
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.
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).
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.
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.
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.
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.
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.
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 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 is 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 "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 is zero.
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.
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.
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.