/** * A decimal number, `coefficient * 10 ** exponent`. * * @evidence contracts/common.md#principled-implementation A decimal number is the pair of an integer coefficient and a power-of-ten exponent, `coefficient * 10^exponent`, which represents a printed number exactly where a double cannot. * @evidence contracts/common.md#clear-and-simple-design Two fields. * @evidence contracts/common.md#prohibited-implementation-shortcuts A data record. * @evidence contracts/common.md#meaningful-documentation A comment states the representation. */ export interface _IDecimal { /** Signed integer digits of the decimal representation. */ coefficient: bigint; /** Power of ten applied to the coefficient. */ exponent: number; } /** * An exact quotient of two big integers. * * @evidence contracts/common.md#principled-implementation An exact quotient is a numerator and a denominator of big integers, so divisibility can be tested by remainder. * @evidence contracts/common.md#clear-and-simple-design Two fields. * @evidence contracts/common.md#prohibited-implementation-shortcuts A data record. * @evidence contracts/common.md#meaningful-documentation A comment states the representation. */ export interface _IDecimalRatio { /** Exact dividend after aligning the decimal exponents. */ numerator: bigint; /** Exact nonzero divisor after aligning the decimal exponents. */ denominator: bigint; } /** * Read a number as the decimal that its shortest string shows. * * @returns The decimal, or `null` for a non-finite number * * @evidence contracts/common.md#principled-implementation The shortest decimal string of the number, which is what JavaScript prints, is split into digits and an exponent: the mantissa digits form the coefficient, the sign is applied and the exponent is the printed exponent minus the number of decimals. Non-finite numbers return null. * @evidence contracts/common.md#clear-and-simple-design One function using string operations and BigInt. * @evidence contracts/common.md#prohibited-implementation-shortcuts The decimal reading is the documented semantics for `multipleOf` and not a tolerance fix. * @evidence contracts/common.md#meaningful-documentation A comment states the reading of a number as its printed decimal and the null case. */ export declare const _decimalDecompose: (value: number) => _IDecimal | null; /** * Divide a number by a decimal exactly. * * @returns The ratio, or `null` for a non-finite value or a zero divisor * * @evidence contracts/common.md#principled-implementation The dividend is decomposed and the exponents are aligned by multiplying the numerator or the denominator by a power of ten, giving an exact ratio; a zero divisor or a non-finite value returns null. * @evidence contracts/common.md#clear-and-simple-design One function over the decomposition and the power helper. * @evidence contracts/common.md#prohibited-implementation-shortcuts The result is exact and no rounding is used. * @evidence contracts/common.md#meaningful-documentation A comment states the ratio and the null cases. */ export declare const _decimalDivide: (value: number, divisor: _IDecimal) => _IDecimalRatio | null; /** * Find the smallest positive integer whose multiples are the integers that are * multiples of a decimal. * * @returns The step, or `null` for a non-finite or non-positive value * * @evidence contracts/common.md#principled-implementation For an integer value to be a multiple of a decimal step `c * 10^e`, the step is the integer itself when the exponent is not negative and otherwise the coefficient divided by its gcd with 10^-e; non-finite and non-positive steps return null. * @evidence contracts/common.md#clear-and-simple-design One function reusing the decomposition, the power and the gcd helper. * @evidence contracts/common.md#prohibited-implementation-shortcuts The result follows from the arithmetic. * @evidence contracts/common.md#meaningful-documentation A comment states the three cases. */ export declare const _decimalIntegerStep: (value: number) => _IDecimal | null; /** * Convert a decimal to the nearest number. * * @evidence contracts/common.md#principled-implementation The decimal is formatted as `coefficient e exponent` text and parsed by Number, which returns the nearest double, so the conversion is exact whenever the decimal is representable and otherwise rounds to the nearest. * @evidence contracts/common.md#clear-and-simple-design One expression. * @evidence contracts/common.md#prohibited-implementation-shortcuts Rounding is stated and callers verify the result where validity matters, as the random multiple helper does. * @evidence contracts/common.md#meaningful-documentation A comment states the nearest-double conversion. */ export declare const _decimalToNumber: (value: _IDecimal) => number; /** * Compute ten to a non-negative integer power exactly. * * @evidence contracts/common.md#principled-implementation Ten to a non-negative integer power is computed with big integers, so it is exact for any exponent. * @evidence contracts/common.md#clear-and-simple-design One expression. * @evidence contracts/common.md#prohibited-implementation-shortcuts A general helper. * @evidence contracts/common.md#meaningful-documentation A one-line comment states what it returns. */ export declare const _decimalPower: (exponent: number) => bigint; /** * Compute the greatest common divisor of two big integers. * * @evidence contracts/common.md#principled-implementation Euclid's remainder iteration accepts the signed integers and returns the absolute final divisor. The absolute remainder decreases on each nonterminal step, so it terminates; two zeros return zero. * @evidence contracts/common.md#clear-and-simple-design One loop. * @evidence contracts/common.md#prohibited-implementation-shortcuts A recognized algorithm. * @evidence contracts/common.md#meaningful-documentation A one-line comment states what it returns. */ export declare const _decimalGcd: (x: bigint, y: bigint) => bigint;