[core] Add pow10_int helper, replace powf in normalize_accuracy and sensor filters (#14114)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
J. Nick Koston
2026-02-24 12:03:24 +13:00
committed by GitHub
co-authored by Claude Opus 4.6
parent 4a52900352
commit 869678953d
3 changed files with 27 additions and 4 deletions
+9 -2
View File
@@ -468,8 +468,15 @@ ParseOnOffState parse_on_off(const char *str, const char *on, const char *off) {
static inline void normalize_accuracy_decimals(float &value, int8_t &accuracy_decimals) {
if (accuracy_decimals < 0) {
auto multiplier = powf(10.0f, accuracy_decimals);
value = roundf(value * multiplier) / multiplier;
float divisor;
if (accuracy_decimals == -1) {
divisor = 10.0f;
} else if (accuracy_decimals == -2) {
divisor = 100.0f;
} else {
divisor = pow10_int(-accuracy_decimals);
}
value = roundf(value / divisor) * divisor;
accuracy_decimals = 0;
}
}