public class ApintMath extends Object
| Modifier and Type | Method and Description |
|---|---|
static Apint |
abs(Apint x)
Absolute value.
|
static Apint[] |
cbrt(Apint x)
Cube root and remainder.
|
static Apint |
copySign(Apint x,
Apint y)
Copy sign from one argument to another.
|
static Apint[] |
div(Apint x,
Apint y)
Quotient and remainder.
|
static Apint |
factorial(long n)
Factorial function.
|
static Apint |
factorial(long n,
int radix)
Factorial function.
|
static Apint |
gcd(Apint a,
Apint b)
Greatest common divisor.
|
static Apint |
lcm(Apint a,
Apint b)
Least common multiple.
|
static Apint |
modMultiply(Apint a,
Apint b,
Apint m)
Modular multiplication.
|
static Apint |
modPow(Apint a,
Apint b,
Apint m)
Modular power.
|
static Apint |
negate(Apint x)
Deprecated.
Use
Apint.negate(). |
static Apint |
pow(Apint x,
long n)
Integer power.
|
static Apint |
product(Apint... x)
Product of numbers.
|
static Apint[] |
root(Apint x,
long n)
Positive integer root and remainder.
|
static Apint |
scale(Apint x,
long scale)
Multiply by a power of the radix.
|
static Apint[] |
sqrt(Apint x)
Square root and remainder.
|
static Apint |
sum(Apint... x)
Sum of numbers.
|
public static Apint pow(Apint x, long n) throws ArithmeticException, ApfloatRuntimeException
x - Base of the power operator.n - Exponent of the power operator.x to the n:th power, that is xn.ArithmeticException - If both x and n are zero.ApfloatRuntimeExceptionpublic static Apint[] sqrt(Apint x) throws ArithmeticException, ApfloatRuntimeException
x - The argument.[q, r], where q2 + r = x.ArithmeticException - If x is negative.ApfloatRuntimeExceptionpublic static Apint[] cbrt(Apint x) throws ApfloatRuntimeException
x - The argument.[q, r], where q3 + r = x.ApfloatRuntimeExceptionpublic static Apint[] root(Apint x, long n) throws ArithmeticException, ApfloatRuntimeException
Returns the n:th root of x,
that is x1/n, rounded towards zero.
x - The argument.n - Which root to take.[q, r], where qn + r = x.ArithmeticException - If n and x are zero, or x is negative and n is even.ApfloatRuntimeException@Deprecated public static Apint negate(Apint x) throws ApfloatRuntimeException
Apint.negate().-x.x - The argument.-x.ApfloatRuntimeExceptionpublic static Apint abs(Apint x) throws ApfloatRuntimeException
x - The argument.x.ApfloatRuntimeExceptionpublic static Apint copySign(Apint x, Apint y) throws ApfloatRuntimeException
x - The value whose sign is to be adjusted.y - The value whose sign is to be used.x with its sign changed to match the sign of y.ApfloatRuntimeExceptionpublic static Apint scale(Apint x, long scale) throws ApfloatRuntimeException
x - The argument.scale - The scaling factor.x * x.radix()scale.ApfloatRuntimeExceptionpublic static Apint[] div(Apint x, Apint y) throws ArithmeticException, ApfloatRuntimeException
x - The dividend.y - The divisor.[quotient, remainder], that is [x / y, x % y].ArithmeticException - In case the divisor is zero.ApfloatRuntimeExceptionpublic static Apint gcd(Apint a, Apint b) throws ApfloatRuntimeException
a
and b is negative.a - First argument.b - Second argument.a and b.ApfloatRuntimeExceptionpublic static Apint lcm(Apint a, Apint b) throws ApfloatRuntimeException
a
and b is negative.a - First argument.b - Second argument.a and b.ApfloatRuntimeExceptionpublic static Apint modMultiply(Apint a, Apint b, Apint m) throws ApfloatRuntimeException
a * b % ma - First argument.b - Second argument.m - Modulus.a * b mod mApfloatRuntimeExceptionpublic static Apint modPow(Apint a, Apint b, Apint m) throws ArithmeticException, ApfloatRuntimeException
a - Base.b - Exponent.m - Modulus.ab mod mArithmeticException - If the exponent is negative but the GCD of a and m is not 1 and the modular inverse does not exist.ApfloatRuntimeExceptionpublic static Apint factorial(long n) throws ArithmeticException, NumberFormatException, ApfloatRuntimeException
n - The number whose factorial is to be calculated. Should be non-negative.n!ArithmeticException - If n is negative.NumberFormatException - If the default radix is not valid.ApfloatRuntimeExceptionpublic static Apint factorial(long n, int radix) throws ArithmeticException, NumberFormatException, ApfloatRuntimeException
n - The number whose factorial is to be calculated. Should be non-negative.radix - The radix to use.n!ArithmeticException - If n is negative.NumberFormatException - If the radix is not valid.ApfloatRuntimeExceptionpublic static Apint product(Apint... x) throws ApfloatRuntimeException
If there are no arguments, the return value is 1.
x - The argument(s).ApfloatRuntimeExceptionpublic static Apint sum(Apint... x) throws ApfloatRuntimeException
If there are no arguments, the return value is 0.
x - The argument(s).ApfloatRuntimeExceptionCopyright © 2025. All rights reserved.