-
Notifications
You must be signed in to change notification settings - Fork 659
feat(math/unstable): add math package with basic math utilities
#6823
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
5b9bc11 to
98eb5e1
Compare
98eb5e1 to
da04151
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6823 +/- ##
==========================================
- Coverage 94.09% 94.08% -0.01%
==========================================
Files 578 582 +4
Lines 42654 42683 +29
Branches 6781 6788 +7
==========================================
+ Hits 40134 40160 +26
- Misses 2469 2471 +2
- Partials 51 52 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
dac2f0f to
132a0be
Compare
132a0be to
004dee2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I often find these utils useful in my personal projects (Especially modulo is necessary for geometry-related programming). I'm in favor of the idea. LGTM
Does anyone have concern/objection about having this (unstable) package?
Closes #6803
clamp: Clamp a number within a range. Based onMath.clampproposal, with a notable difference being that current proposal specifiesTypeErrors forNaNinputs, whereas my version returnsNaNs, because throwingTypeErrors seems rather unexpected given the corresponding behavior ofMath.minandMath.max.modulo: Floor modulo operation, in contrast with JS's%remainder operator. Based on Python's%(floor modulo) operator and modulus math proposal.round-to: Round a number to a specified number of decimal places using various rounding strategies. BasicallyNumber#toFixedbut returning a number instead of a string.Probably worth kicking the wheels for things like floating-point rounding issues, in cases where those are avoidable or optimizable.