Closed
Description
Question
What is the expected behavior for the following inputs?
new Decimal("0.1000000000_0000000000_0000000000_1111_4")
new Decimal("0.1000000000_0000000000_0000000000_1111_5")
new Decimal("0.1000000000_0000000000_0000000000_1111_6")
new Decimal("0.1000000000_0000000000_0000000000_1112_4")
new Decimal("0.1000000000_0000000000_0000000000_1112_5")
new Decimal("0.1000000000_0000000000_0000000000_1112_6")
The decimal inputs above has 35 decimals and 35 significant decimals
- Should the specification define the behavior for such input?
- If yes, should it be:
- undefined, thus up to implementor?
- truncate?
- round halfEven?
- throw error?
From my reading, currently specification only mention ParseText
, but ParseText
does not provide detail on how such input should be handled.
Ref: https://tc39.es/proposal-decimal/#sec-the-decimal128-constructor-value
Side note
the npm package decimal128 @ 22:
new Decimal("0.00000_0000000000_9999999999_9999999999_9999999999_99915").toString()
x | v |
---|---|
input | "0.00000_0000000000_9999999999_9999999999_9999999999_99915" |
current | "0.00000_0000000001" |
expected | "0.00000_0000000000_9999999999_9999999999_9999999999_9992" |
^ expectation assuming round halfEven
Metadata
Metadata
Assignees
Labels
No labels