34 lines
453 B
C++
34 lines
453 B
C++
![]() |
/*
|
||
|
* utils.cpp
|
||
|
*
|
||
|
* Created on: Feb 11, 2015
|
||
|
* Author: wn
|
||
|
*/
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
#include "utils.h"
|
||
|
|
||
|
|
||
|
int32_t max(int32_t a, int32_t b){
|
||
|
return (a >= b) ? a : b;
|
||
|
}
|
||
|
|
||
|
|
||
|
int32_t min(int32_t a, int32_t b) {
|
||
|
return (a <= b) ? a : b;
|
||
|
}
|
||
|
|
||
|
int32_t minmax(int32_t lowerBound, int32_t value, int32_t upperBound){
|
||
|
int32_t res = value;
|
||
|
if (value <= lowerBound) {
|
||
|
res = lowerBound;
|
||
|
} else if (value >= upperBound) {
|
||
|
res = upperBound;
|
||
|
}
|
||
|
return res;
|
||
|
}
|
||
|
|
||
|
|