Skip to content

Add clamp to scala.math and numeric types #55

Open
@exoego

Description

@exoego

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.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requeststatus:pendingThis enhancement request lacks consensus on whether or not to include it

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions