[dlms_meter/kamstrup_kmp] Replace powf with pow10_int (#14125)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
J. Nick Koston
2026-02-24 18:44:50 -06:00
committed by GitHub
parent 2ff876c629
commit 3460a8c922
2 changed files with 4 additions and 6 deletions

View File

@@ -1,7 +1,5 @@
#include "dlms_meter.h"
#include <cmath>
#if defined(USE_ESP8266_FRAMEWORK_ARDUINO)
#include <bearssl/bearssl.h>
#elif defined(USE_ESP32)
@@ -410,7 +408,7 @@ void DlmsMeterComponent::decode_obis_(uint8_t *plaintext, uint16_t message_lengt
if (current_position + 1 < message_length) {
int8_t scaler = static_cast<int8_t>(plaintext[current_position + 1]);
if (scaler != 0) {
value *= powf(10.0f, scaler);
value *= pow10_int(scaler);
}
}

View File

@@ -222,11 +222,11 @@ void KamstrupKMPComponent::parse_command_message_(uint16_t command, const uint8_
}
// Calculate exponent
float exponent = msg[6] & 0x3F;
int8_t exp_val = msg[6] & 0x3F;
if (msg[6] & 0x40) {
exponent = -exponent;
exp_val = -exp_val;
}
exponent = powf(10, exponent);
float exponent = pow10_int(exp_val);
if (msg[6] & 0x80) {
exponent = -exponent;
}