better efiRound implementation

This commit is contained in:
rusefi 2017-12-10 10:19:05 -05:00
parent 373da8607f
commit 148fea5574
2 changed files with 12 additions and 1 deletions

View File

@ -21,10 +21,17 @@ int minI(int i1, int i2) {
return i1 < i2 ? i1 : i2;
}
float efiRound(float value, float precision) {
/*
float efiFloat(float value, float precision) {
int a = (int) (value / precision);
return a * precision;
}
*/
float efiRound(float value, float precision) {
float a = rintf (value / precision);
return a * precision;
}
float absF(float value) {
return value > 0 ? value : -value;

View File

@ -51,6 +51,10 @@ int atoi(const char *string);
int absI(int32_t value);
float absF(float value);
/**
* Rounds value to specified precision.
* @param precision some pow of 10 value - for example, 100 for two digit precision
*/
float efiRound(float value, float precision);
int maxI(int i1, int i2);
int minI(int i1, int i2);