Skip to content
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

Add clamp to scala.math and numeric types #11778

Open
exoego opened this issue Oct 25, 2019 · 0 comments · May be fixed by scala/scala#8510

Comments

@exoego
Copy link

@exoego exoego commented Oct 25, 2019

Clamping numbers between an upper and lower bound is a relatively-common task, specially in graphics domain.

Currently, Java and Scala standard library does not offer such functionality, so users need to write something like max(LOWER_BOUND, min(VALUE, UPPER_BOUND)) which is error-prone.

I propose adding clamp function to math.
Adding clamp to numeric types (e.g. Int or Double) may be good to have, in analogus to max/min.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.