Add a config object and approximate equality #18
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
One feature in pocomath and mathjs 14 is that generally speaking, number equality is checked with some numerical fuzziness, allowing numbers that are very close to be considered equal. This convention seems to be a response to roundoff errors that occur in floating point calculations, preventing such issues as 0.1 + 0.2 not being equal to 0.3. Of course, it creates other issues; for example, approximate equality is not transitive: we can find numbers a, b, c such that a and b are considered equal, and b and c are considered equal, but a and c are not considered equal.
Nevertheless, in an effort to conform to existing conventions in mathjs (and in particular to make sure we produce the same results on the polynomialRoot test), we need to implement a configuration object and set tolerances for approximate equality.
However, experience has shown in the mathjs world that it would be best to have different values of these tolerance parameters for different types. And nanomath has the ability for any property to be indexed by type. So I think we should just set things up so that
math.resolve('config', [BigNumber])
gives the bignumber configuration.One might reasonably wonder whether something like the tolerance parameters that seem well-tied to a specific type is an exception, and that at least not the entire config object should be tied to type. However, reviewing other config settings, it seems that many of them could plausibly be construed to do with type. For example,
predictable
that says whether to return a complex square root might be something someone would want to vary by input type, So for now I will just go with this plan.