36 return (
rand() % (range + 1));
47 rand(int16_t low, int16_t high)
49 return (
rand() % (high - low + 1) + low);
61 return (
random() % (range + 1));
74 return (
random(high - low + 1) + low);
85 inline uint8_t
log2(T value)
105 template<
class T, T in_min, T in_max, T out_min, T out_max>
108 static_assert(in_min < in_max,
"bad range for map function");
109 static_assert(out_min < out_max,
"bad domain for map function");
110 if (
UNLIKELY(x < in_min))
return (out_min);
111 if (
UNLIKELY(x > in_max))
return (out_max);
112 T range = in_max - in_min;
113 T domain = out_max - out_min;
114 return ((((x - in_min) * domain) / range) + out_min);
125 template<
class T, T low, T high>
128 static_assert(low < high,
"bad range for contrain function");
129 return (x < low ? low : (x > high ? high : x));
141 template<
class T, T low, T high>
144 return (!(x < low || x > high));
uint16_t rand(uint16_t range)
uint32_t random(uint32_t range)
#define static_assert(condition, message)