@tempots/std
Version:
Std library for TypeScript. Natural complement to the Tempo libraries.
156 lines (155 loc) • 4.74 kB
TypeScript
/**
* Calculates the ceiling division of two BigInt numbers.
*
* @param x - The dividend.
* @param y - The divisor.
* @returns The result of dividing `x` by `y`, rounded up to the nearest whole number.
* @public
*/
export declare const biCeilDiv: (x: bigint, y: bigint) => bigint;
/**
* Divides two BigInt numbers and returns the largest integer less than or equal to the quotient.
*
* @param x - The dividend.
* @param y - The divisor.
* @returns The largest integer less than or equal to the quotient of `x` divided by `y`.
* @public
*/
export declare const biFloorDiv: (x: bigint, y: bigint) => bigint;
/**
* Compares two BigInt values and returns a number indicating their relative order.
* @param x - The first BigInt value to compare.
* @param y - The second BigInt value to compare.
* @returns A negative number if `x` is less than `y`, a positive number if `x` is greater than `y`,
* @public
* or zero if `x` is equal to `y`.
*/
export declare const biCompare: (x: bigint, y: bigint) => number;
/**
* Returns the absolute value of a bigint.
*
* @param x - The bigint to compute the absolute value of.
* @returns The absolute value of `x`.
* @public
*/
export declare const biAbs: (x: bigint) => bigint;
/**
* Returns the minimum of two BigInt values.
*
* @param x - The first BigInt value.
* @param y - The second BigInt value.
* @returns The smaller of the two BigInt values.
* @public
*/
export declare const biMin: (x: bigint, y: bigint) => bigint;
/**
* Returns the maximum of two BigInt values.
*
* @param x - The first BigInt value.
* @param y - The second BigInt value.
* @returns The maximum of the two BigInt values.
* @public
*/
export declare const biMax: (x: bigint, y: bigint) => bigint;
/**
* Calculates the power of a bigint number.
*
* @param x - The base number.
* @param y - The exponent.
* @returns The result of raising `x` to the power of `y`.
* @public
* @throws Throws `ArgumentError` if the exponent `y` is negative.
*/
export declare const biPow: (x: bigint, y: bigint) => bigint;
/**
* Calculates the greatest common divisor (GCD) of two BigInt numbers.
*
* @param x - The first BigInt number.
* @param y - The second BigInt number.
* @returns The GCD of `x` and `y`.
* @public
*/
export declare const biGcd: (x: bigint, y: bigint) => bigint;
/**
* Calculates the least common multiple (LCM) of two BigInt numbers.
*
* @param x - The first BigInt number.
* @param y - The second BigInt number.
* @returns The least common multiple of `x` and `y`.
* @public
*/
export declare const biLcm: (x: bigint, y: bigint) => bigint;
/**
* Checks if a given number is prime.
*
* @param x - The number to check for primality.
* @returns `true` if the number is prime, `false` otherwise.
* @public
*/
export declare const biIsPrime: (x: bigint) => boolean;
/**
* Finds the next prime number greater than the given number.
*
* @param x - The starting number.
* @returns The next prime number greater than `x`.
* @public
*/
export declare const biNextPrime: (x: bigint) => bigint;
/**
* Returns the previous prime number less than the given number.
* Throws an error if there is no previous prime.
*
* @param x - The number to find the previous prime for.
* @returns The previous prime number less than `x`.
* @public
* @throws Throws `ArgumentError` if there is no previous prime.
*/
export declare const biPrevPrime: (x: bigint) => bigint;
/**
* Checks if a given bigint is even.
*
* @param x - The bigint to check.
* @returns `true` if the bigint is even, `false` otherwise.
* @public
*/
export declare const biIsEven: (x: bigint) => boolean;
/**
* Checks if a given bigint is odd.
*
* @param x - The bigint to check.
* @returns `true` if the bigint is odd, `false` otherwise.
* @public
*/
export declare const biIsOdd: (x: bigint) => boolean;
/**
* Checks if a given bigint is zero.
*
* @param x - The bigint to check.
* @returns `true` if the bigint is zero, `false` otherwise.
* @public
*/
export declare const biIsZero: (x: bigint) => boolean;
/**
* Checks if a given bigint is equal to 1n.
*
* @param x - The bigint to check.
* @returns `true` if the bigint is equal to 1n, `false` otherwise.
* @public
*/
export declare const biIsOne: (x: bigint) => boolean;
/**
* Checks if a given bigint is negative.
*
* @param x - The bigint to check.
* @returns `true` if the bigint is negative, `false` otherwise.
* @public
*/
export declare const biIsNegative: (x: bigint) => boolean;
/**
* Checks if a bigint is positive.
*
* @param x - The bigint to check.
* @returns `true` if the bigint is positive, `false` otherwise.
* @public
*/
export declare const biIsPositive: (x: bigint) => boolean;