going fancy to allow static_assert

This commit is contained in:
rusefi 2023-10-13 16:49:39 -04:00
parent 6a1d9d4777
commit efa16b1b9b
2 changed files with 6 additions and 10 deletions

View File

@ -7,8 +7,12 @@
#include <cstddef>
// absolute value
int absI(int value);
float absF(float value);
constexpr int absI(int value) {
return value > 0 ? value : -value;
}
constexpr float absF(float value) {
return value > 0 ? value : -value;
}
// Min/max
int maxI(int i1, int i2);

View File

@ -2,14 +2,6 @@
#include <cstdint>
float absF(float value) {
return value > 0 ? value : -value;
}
int absI(int value) {
return value >= 0 ? value : -value;
}
int maxI(int i1, int i2) {
return i1 > i2 ? i1 : i2;
}