3 ms·
Python also doesn't have a built-in clamp function (I think there might be one in numpy), I usually use sorted((floor, x, ceiling))[1] Throw it in a funct
by parliament32 6y ago
Python also doesn't have a built-in clamp function (I think there might be one in numpy), I usually use
sorted((floor, x, ceiling))[1]
Throw it in a function with some asserts if you're worried about x not being a number and giving you weird results.