Where can I find clamp in the C# class library?
Posted
by Danvil
on Stack Overflow
See other posts from Stack Overflow
or by Danvil
Published on 2010-04-21T13:47:37Z
Indexed on
2010/04/21
13:53 UTC
Read the original article
Hit count: 477
c#
I would like to clamp a value x
to a range [a, b]
:
T x = (x < a) ? a : ((x > b) ? b : x);
This is quite basic. But I do not see a function "clamp" in the class library - at least not in System.Math
.
© Stack Overflow or respective owner