All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- We now emit a single JS file in the
dist
directory rather than several JS module files. No need for ESM or CJS subdirectories anymore.
- Use JSBI in favor of native JS bigints (thanks @amoshydra)
- Fix exports in package.json (thanks @amoshydra)
- Some dead code has been deleted.
- We now emit CommonJS and ESM modules. The ESM and CJS are now found, respecively, in the
dist/esm
anddist/cjs
directories.
- Updated dependencies. No user-visible changes are expected.
- Support for quantum/precision, including support for trailing zeroes. This is a breaking change if you're using these features.
The purpose of these changes is to align the API with the official spec.
- Use the official IEEE 754 rounding names rather than "trunc", "ceil", etc. This is a breaking change if you're using those rounding modes. If not, you shouldn't see any change.
- Support for converting decimals to BigInts (
toBigInt
) and Numbers (toNumber
). - Relax the constructor to allow all Number arguments (in addition to BigInts and strings).
- Unsupported/inofficial rounding modes. We support the official IEEE Decimal128 ones: trunc, ceil, floor, halfEven, halfUp.
- Rounding options for arithmetic operations. The rounding mode is now always, implicitly,
halfEven
. Rounding is still supported in the constructor.
compare
method for comparting Decimal128 objects as digit strings, not as mathematical values (models IEEE 754'scompare_total
operation)
- The remainder operation no longer takes an optional argument for specifying the rounding mode. It is unnecessary.
- New negation operator
neg
- The
normalize
option forlessThan
andequals
has been removed. The comparison is now always done on the mathematical value.
- The Decimal128 constructor now accepts BigInt arguments as well as safe integer Numbers
- For
lessThan
andequals
: the property of the (optional) second argumenttotal
has been renamed tonormalize
valueOf
throws unconditioanlly to prevents any kind of mixing of Decimal128 objects with other JS valueslessThan
to determine whether a Decimal128 is strictly less than another Decimal128equals
to determine whether a Decimal128 value is mathematically equal to another one
cmp
has been removed in favor oflessThan
andequals
for a nicer API
No code changes. A few more examples of cmp
in action were added to the test suite.
abs
method for computing absolute value
- Added an option to
cmp
to normalize values values before comparison (default istrue
, i.e., compare mathematical values).
normalize
method (can now be safely defined in user space asnew Decimal128(x.toString())
.- Option to normalize strings in the constructor (we now accept the given digit string as-is)
- Restore possibility to specify rounding mode in arithmetic operations and constructor (#72)
- Addition, subtraction, multiplication, division, and remainder are now static methods. This is a breaking change.
sqrt
pow
reciprocal
truncate
,floor
, andceil
(useround
instead)
- Rounding modes for all operations (#54)
- LICENSE file
- Ensure that the NPM package is nice and lean (#57) by removing unnecessary files and dependencies
toExponentialString
: Output a sign (+
or-
) in the exponent part. This is a breaking change.- Fused multiply-and-add (
multiplyAdd
)
- Square root operation
- Internal change in the representation of not-a-number and +/- infinity. No user-visible changes.
- We now support non-normalized decimals, i.e. decimals with a non-zero integer part. This is a breaking change for some use cases. In this approach, trailing zeros are not removed; they are considered significant. For instance,
0.25
plus0.75
is now1.00
, not1
.
round
now takes a number argument (default 0) to specify the index of the decimal digit after which rounding should take place (#45)
pow
for raising a decimal to a power (#43)