How should the BigDecimal constructor round Numbers?
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 638
- Forks
- 20
- PR merge metrics
- No merged PRs in 30d
Description
A couple options, suggested by Fabrice Bellard:
(1) BigDecimal(0.1) = 0.1d (i.e. use Number.prototype.toString() and then convert the string to bigdecimal).
(2) BigDecimal(0.1) = 0.1000000000000000055511151231257827021181583404541015625d
(2) is mathematically correct but may be surprising, so I selected (1).
I have to say, I was really expecting (2), but (1) may be more practical. One way to think of a Number is an exact quantity, and another way is to think of it as a range within the ulp.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read the issue discussion and compare the two proposed BigDecimal constructor behaviors for Number values. The issue does not name files, tests, or an implementation entry point; done would require a decided rounding rule and corresponding project changes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- data
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100