feat(NODE-5594): add Decimal128.fromStringWithRounding() static method #617
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
What is changing?
Decimal128.fromStringWithRounding
static methodtest/node/decimal128_tests.js
to typescript and add tests forfromStringWithRounding
Is there new documentation needed for these changes?
What is the motivation for this change?
NODE-5594
Release Highlight
Adds new
Decimal128.fromStringWithRounding
static methodPrior to the 6.0.0 release,
Decimal128.fromString
performed rounding behaviour by default that rounded numbers with >34 significant digits incorrectly. In addition to this bug, the intention of theDecimal128
type and specification is to provide an interface to a high-precision floating point value, so rounding by default also went against this intention, which is why that behaviour was removed from the method in the 6.0.0 release.We understand that some users may have come to rely on the rounding behaviour, so that has been corrected here and exposed via a new static method,
Decimal128.fromStringWithRounding
, which should now allow these users to migrate to the v6 of the driver.Thank you to @hconn-riparian for reporting a related rounding bug and fix in #560 which has been included in this feature.
Double check the following
npm run check:lint
scripttype(NODE-xxxx)[!]: description
feat(NODE-1234)!: rewriting everything in coffeescript