I came across this question: How to deal with floating point number precision in JavaScript? which is flagged as a duplicate of Is floating point math broken?.
The problem is that the first question is asking specifically about JavaScript solutions, while the supposed duplicate is language-agnostic, and more about the general theory of floating point math (it appears that back in 2009 the question referred to JavaScript, but it no longer does). As such, I don't agree that they are duplicates. If I want to find a quality JavaScript solution to the issue, I'd like to read answers specifically about JavaScript.
I voted to reopen the question, but it now says:
The community reviewed whether to reopen this question 14 days ago and left it closed:
Original close reason(s) were not resolved
Can someone shed light on why this is the case?
If there's a way to improve the question, I'm open to doing so, however I think the question is quite reasonable as is.
I remain stuck with knowing where to find or contribute a thorough answer that:
- Suggests an explanation for why floating point errors occur
- Explains common theoretical approaches for dealing with the problem
- Also includes some short JavaScript code examples
- Warns about potential pitfalls of the built-in JavaScript functions (e.g. that they return strings, that precision may be lost) and suggests potential workarounds
The canonical thread does #1 and #2, but not #3 or #4. Is this kind of answer not welcome anywhere on Stack Overflow? Or does it have to be part of a much narrower and more focused question? In my opinion it would be laborious to have to hunt through multiple questions to gather information on various approaches, when a clear summary would get readers started.
It appears that there is a similar question related to floating point arithmetic in Java that has become somewhat of a canonical, see How to avoid floating point precision errors with floats or doubles in Java?
Is there really no value in having a JavaScript canonical question about floating point precision that covers all 4 (while linking to the main canonical for the general theory and background)?