//#region src/math.d.ts /** * @classytic/tax-core/math — the ONE implementation of a tax rate applied to an integer minor-unit * amount. Every pack's `computeLine` and the document algorithm call these; none divides by * `1 + rate` in floating point. * * Rounding: half away from zero on the TAX amount, in integer minor units. A rate is an exact * rational — a percent with at most four decimals (15, 7.5, 2.4, 9.975) — so no rounding happens * before the final quotient. */ /** Thrown when a rate is not a finite percent in [0, 100] with at most four decimals. */ declare class InvalidTaxRateError extends Error { readonly ratePercent: number; readonly code = "INVALID_TAX_RATE"; constructor(ratePercent: number); } /** A percent as an exact integer of 1/10_000ths of a percent: 15 → 150_000n, 7.5 → 75_000n. */ declare function scaledRate(ratePercent: number): bigint; /** `numerator / denominator` rounded half away from zero, exactly. `denominator` must be positive. */ declare function divideHalfUp(numerator: bigint, denominator: bigint): bigint; /** Tax ADDED to a tax-exclusive amount: `amount × R / 100`. */ declare function taxOnExclusive(amountMinor: number, ratePercent: number): number; /** * Tax INCLUDED in a tax-inclusive amount — the tax fraction `R / (100 + R)` of the consideration. * The net is the amount minus this, so `net + tax === amount` exactly. */ declare function taxInInclusive(amountMinor: number, ratePercent: number): number; //#endregion export { InvalidTaxRateError, divideHalfUp, scaledRate, taxInInclusive, taxOnExclusive };