This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Your PR looks good @rnd-debug , thanks 👍 . Let's just ignore the codecov warnings, I'm not sure what's going on there but the new functionality is well tested.
A few feedback points:
Can you add the new syntax math.floor(x, n) to the main comment in floor.js (used for the docs), like you did for math.ceil(x, n)?
I didn't think about it before, but maybe we should also implement rounding with precision for the function fix, then all related functions (round, floor, ceil, fix) have the same behavior. What do you think?
@josdejong I am confused about how to deal with rounding errors.
Similar issues can appear with mathjs.ceil. Should we be compliant to the external library?
If you calculate ceil(0.1 + 0.2, 1), what whould you expect to get? 0.1 + 0.2 returns 0.30000000000000004, and technically ceil(0.30000000000000004, 1) should return 0.4. But that's not what we expect: we expect the result to be 0.3, right?
To work around these issues with equal, larger, smaller, but also ceil, fix, floor in mathjs, we first apply a rounding to EPSILON (1e-12 by default) to get rid of those round off errors. After that, we can do the actualy thing we want to do: checking equality, or applying ceil/fix/floor. Does that make sense?
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.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.