▲ | xmprt 15 hours ago | ||||||||||||||||
Maybe it's different since you're not native English but clamp is as intuitive for me as something like ceil or floor methods. It might not be as simple for someone who is ESL, probably because no major programming languages that I know of include clamp in their standard library like they do with min, max, ceil, floor. I'm also coming from being a Go programmer where the native library is very barebones so a lot of custom utility methods like this are inevitable. | |||||||||||||||||
▲ | aero_code 14 hours ago | parent | next [-] | ||||||||||||||||
FYI, some major programming languages have clamp: C++: https://en.cppreference.com/w/cpp/algorithm/clamp.html .NET/C#: https://learn.microsoft.com/en-us/dotnet/api/system.math.cla... Java: https://docs.oracle.com/en/java/javase/24/docs/api/java.base... Ruby: https://ruby-doc.org/core-2.4.0/Comparable.html#method-i-cla... Rust: https://doc.rust-lang.org/stable/std/primitive.f64.html#meth... | |||||||||||||||||
| |||||||||||||||||
▲ | TRiG_Ireland 3 hours ago | parent | prev [-] | ||||||||||||||||
I am a native English speaker, and I've never heard of "clamp" before. Admittedly, most of my programming experience is in PHP, and I've rarely done anything with much maths. |