diff --git a/src/cmath.h b/src/cmath.h index ffd6128..53e5d18 100644 --- a/src/cmath.h +++ b/src/cmath.h @@ -9,19 +9,19 @@ // AVR libc doesn't support cmath #include -// Use builtin functions for min/max/abs template static inline const T min(T a, T b) { - return __builtin_min((a, b)); + return a <= b ? a : b; } template static inline const T max(T a, T b) { - return __builtin_max((a, b)); + return a > b ? a : b; } template static inline const T abs(T n) { + // Use builtin function when available return __builtin_abs((n)); }