import { formatNumber } from './formatNumber'; import { _isFinite, _isInfinite, _isNaN, abs, aIsEqualToB, aIsLessThanB, aIsMoreThanB, formatScientificNotationNumber, isNegativeNumber, isStrNumber } from './share'; import { trunc } from './trunc'; declare global { type StrNumberValue = string | typeof StrNumber.NEGATIVE_INFINITY | typeof StrNumber.POSITIVE_INFINITY | typeof StrNumber.NaN; type StrNumberType = number | StrNumberValue | StrNumber; } /** * 私有value属性名 */ declare const privateValueKey: unique symbol; /** * 类名:StrNumber * @description * 这是一个数字计算类,用于解决js浮点数运算精度丢失和大数运算的问题 * 封装了常用的加减乘除计算方法,还包括toFixed方法 * 实例支持链式调用计算方法,计算方法也可以在静态方法中调用 */ declare class StrNumber { /** 正无穷 */ static POSITIVE_INFINITY: import("./StrNumberFlag").default; /** 负无穷 */ static NEGATIVE_INFINITY: import("./StrNumberFlag").default; /** 不存在的数字 */ static NaN: import("./StrNumberFlag").default; /** 计算两数之和 */ static add: (a: StrNumberType, b: StrNumberType) => StrNumberValue; /** 计算两数之差 */ static minus: (a: StrNumberType, b: StrNumberType) => StrNumberValue; /** 计算两数之积 */ static times: (a: StrNumberType, b: StrNumberType) => StrNumberValue; /** 计算两数之商 */ static into: (a: StrNumberType, b: StrNumberType) => StrNumberValue; /** 计算公式字符串 */ static calc: (str: string) => StrNumberValue; /** 指定小数位数,超出四舍五入,不足补0 */ static toFixed: (value: StrNumberType, digits: number) => string; /** 截断小数位数,超出舍弃,不足补0 */ static trunc: typeof trunc; /** 判断是否为负数 */ static isNegativeNumber: typeof isNegativeNumber; /** 判断数值是否是无限的 */ static isInfinite: typeof _isInfinite; /** 判断数值是否是有限的 */ static isFinite: typeof _isFinite; /** 判断数值是否是NaN */ static isNaN: typeof _isNaN; /** 判断是否是StrNumber类型 */ static isStrNumber: typeof isStrNumber; /** 将科学计数法转换为字符数字 */ static formatScientificNotationNumber: typeof formatScientificNotationNumber; /** 判断A是否等于B */ static aIsEqualToB: typeof aIsEqualToB; /** 判断A是否大于B */ static aIsMoreThanB: typeof aIsMoreThanB; /** 判断A是否小于B */ static aIsLessThanB: typeof aIsLessThanB; /** 取绝对值 */ static abs: typeof abs; /** 数字字符串格式化,用于不规则参数归一化 */ static formatNumber: typeof formatNumber; /** * 私有value属性 * 给value属性做存值 */ private [privateValueKey]; value: StrNumberValue; constructor(value?: any); private calc; /** * 加 */ add(...value: StrNumberType[]): StrNumber; /** * 减 */ minus(...value: StrNumberType[]): StrNumber; /** * 乘 */ times(...value: StrNumberType[]): StrNumber; /** * 除 */ into(...value: StrNumberType[]): StrNumber; /** * 小于 */ isLessThan(value: StrNumberType): boolean; /** * 等于 */ isEqualTo(value: StrNumberType): boolean; /** * 大于 */ isMoreThan(value: StrNumberType): boolean; /** * 指定小数位数,超出四舍五入,不足补0 * @param digits 小数位数 */ toFixed(digits: number): string; /** * 截断小数位数,超出舍弃,不足补0 * @param digits 小数位数 */ trunc(digits: number): string; /** * 支持原生String方法转换字符串 */ toString(): string; /** * 原始值转换为数字 */ valueOf(): number; } export default StrNumber;