clamp
lib callCapy
function clamp(value : f32, low : f32, high : f32) f32 function clamp(value : f64, low : f64, high : f64) f64 function clamp(value : s8, low : s8, high : s8) s8 function clamp(value : s16, low : s16, high : s16) s16 function clamp(value : s32, low : s32, high : s32) s32 function clamp(value : s64, low : s64, high : s64) s64 function clamp(value : u8, low : u8, high : u8) u8 function clamp(value : u16, low : u16, high : u16) u16 function clamp(value : u32, low : u32, high : u32) u32 function clamp(value : u64, low : u64, high : u64) u64
Description
clamp(value, low, high) equals min(max(value, low), high). The bounds are inclusive. A low greater than high returns high.
Parameters
value : the number to limit
low : the smallest allowed result
high : the largest allowed result
Return Values
low when value is below it, high when above it, otherwise value. All three share one type.
Example
Capy
print(clamp(75, 1, 50), " ", clamp(1.7, 0.0, 1.0), " ", clamp(-3, 0, 10), "\n")
Output
50 1 0