import type { SAdd } from "./Add"; import type { SDiv } from "./Div"; import type { SMul } from "./Mul"; import type { SAdd as SAddNat } from "./Nat/Add"; import type { SCompare as SCompareNat } from "./Nat/Compare"; import type { LT } from "./aliases"; import type { _CanStrToLiteralNum } from "./internals/_CanStrToLiteralNum"; import type { _Div10 } from "./internals/_Div10"; import type { _StrToNum } from "./internals/_StrToNum"; /** * Calculate the exponentiation of a `number`. * * Uses Taylor series to calculate the exponentiation, and the default iteration precision is `10`. * * Sig: `(n: number, precision?: number) => number` * * @example * ```typescript * type R1 = Exp<2>; * // ^?: 7.388712522045852 * type R2 = Exp<3>; * // ^?: 20.063392857142855 * ``` */ export type Exp = N extends N ? number extends N ? number : _StrToNum> : never; /** * Calculate the exponentiation of the string representation of a `number`. * * Uses Taylor series to calculate the exponentiation, and the default iteration precision is `10`. * @private */ export type SExp = ( N extends `-${infer N}` ? SDiv<"1", _SExp> : _SExp ) extends infer R extends string ? R : never; type _SExp< N extends string, Precision extends string, I extends string, Term extends string, Result extends string, > = SCompareNat extends LT ? SMul> extends infer NextTerm extends string ? _SExp, NextTerm, SAdd> : never : Result;