Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

c++ clip values

template <typename T>
T clip(const T& n, const T& lower, const T& upper) {
  return std::max(lower, std::min(n, upper));
}

// Credit: https://stackoverflow.com/questions/9323903/most-efficient-elegant-way-to-clip-a-number
 
PREVIOUS NEXT
Tagged: #clip #values
ADD COMMENT
Topic
Name
8+2 =