Repository navigation
This version adds significantDigits to format(), making it easier to display small amounts without counting their leading zeros.
dn.format([126n, 8], { significantDigits: 1 }); // "0.000001"
dn.format([126n, 8], { significantDigits: 2 }); // "0.0000013"Combine it with digits to keep normal decimal formatting while preserving more detail for small amounts:
dn.format([126n, 8], { digits: 2, significantDigits: 2 }); // "0.0000013"It supports the existing rounding, trailing-zero, locale, and sign options. significantDigits must be a positive safe integer and cannot be combined with compact: true.
Also adds a README example showing how to read a token balance and pass a Dnum amount to a contract call.
Thanks @yodlmeister and @carpntr for the small-amount formatting suggestion and examples, and @elee1766 for suggesting the contract documentation 🙏