diff options
author | Aaron Watry <awatry@gmail.com> | 2013-04-16 18:31:56 -0500 |
---|---|---|
committer | Aaron Watry <awatry@gmail.com> | 2013-04-16 18:31:56 -0500 |
commit | c54e23e40661c40e4da407a00c9c381dfd65716e (patch) | |
tree | 3405ad954038ee1671ceeeaa2166bb8a485ddefd | |
parent | 91a72d1726ae726601255b2ed51475b0495e6bb4 (diff) |
libclc: simplify clamp() by using min()/max()
-rw-r--r-- | generic/lib/shared/clamp.inc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/generic/lib/shared/clamp.inc b/generic/lib/shared/clamp.inc index 58370d3..c1cd1aa 100644 --- a/generic/lib/shared/clamp.inc +++ b/generic/lib/shared/clamp.inc @@ -1,9 +1,9 @@ _CLC_OVERLOAD _CLC_DEF GENTYPE clamp(GENTYPE x, GENTYPE y, GENTYPE z) { - return (x > z ? z : (x < y ? y : x)); + return min(max(x,y),z); } #ifndef SCALAR _CLC_OVERLOAD _CLC_DEF GENTYPE clamp(GENTYPE x, SCALAR_GENTYPE y, SCALAR_GENTYPE z) { - return (x > (GENTYPE)z ? (GENTYPE)z : (x < (GENTYPE)y ? (GENTYPE)y : x)); + return min(max(x,y),z); } #endif
\ No newline at end of file |