Skip to content

2.18.2

Latest

Choose a tag to compare

@bpierre bpierre released this 04 Dec 18:35
911d6ed

This version fixes double rounding in divide() and improves scientific notation parsing in from().

dn.divide("2.999", 2, 0); // [1n, 0] (previously [2n, 0])
dn.from("1E2"); // [100n, 0]
dn.from("1e0"); // [1n, 0]

from() now rejects malformed numbers like "1example" and accepts exponents from −1,000,000 to 1,000,000. Scientific notation parsing is faster on both Bun and Node, and dnum has no runtime dependencies.

Decimal scales must be nonnegative safe integers. If you write JSON for fromJSON() yourself, quote the coefficient to preserve its precision, as in ["9007199254740993", 0]. Values written by toJSON() already use this format.

See #34, #35, and #36 for details.