temperature converter: Replace division with multiplication. This makes the code faster
This commit is contained in:
parent
ab4499a284
commit
80edd09528
@ -68,7 +68,7 @@ int temp_converter_convert_resistance_to_temp(float resistance, float *temp_out)
|
||||
diff_to_low_resistance = resistance - (float)(TEMP_CONVERSION_MIN_RES + TEMP_CONVERSION_RES_STEP * lower_idx);
|
||||
|
||||
/* Calculate output temperature */
|
||||
*temp_out = (diff_to_low_resistance / TEMP_CONVERSION_RES_STEP) * diff_high_low + low;
|
||||
*temp_out = (diff_to_low_resistance * (1.0f / TEMP_CONVERSION_RES_STEP)) * diff_high_low + low;
|
||||
|
||||
return_ret_val:
|
||||
return ret_val;
|
||||
|
Loading…
Reference in New Issue
Block a user