BigIntDecimal.d.ts 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. import type { DecimalClass, ValueType } from './interface';
  2. export default class BigIntDecimal implements DecimalClass {
  3. origin: string;
  4. negative: boolean;
  5. integer: bigint;
  6. decimal: bigint;
  7. /** BigInt will convert `0009` to `9`. We need record the len of decimal */
  8. decimalLen: number;
  9. empty: boolean;
  10. nan: boolean;
  11. constructor(value: string | number);
  12. private getMark;
  13. private getIntegerStr;
  14. /**
  15. * @private get decimal string
  16. */
  17. getDecimalStr(): string;
  18. /**
  19. * @private Align BigIntDecimal with same decimal length. e.g. 12.3 + 5 = 1230000
  20. * This is used for add function only.
  21. */
  22. alignDecimal(decimalLength: number): bigint;
  23. negate(): BigIntDecimal;
  24. private cal;
  25. add(value: ValueType): BigIntDecimal;
  26. multi(value: ValueType): BigIntDecimal;
  27. isEmpty(): boolean;
  28. isNaN(): boolean;
  29. isInvalidate(): boolean;
  30. equals(target: DecimalClass): boolean;
  31. lessEquals(target: DecimalClass): boolean;
  32. toNumber(): number;
  33. toString(safe?: boolean): string;
  34. }