mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
fix render_value float, leading zeros to decimals
This commit is contained in:
@@ -262,6 +262,11 @@ char * Helpers::render_value(char * result, const float value, const int8_t form
|
||||
|
||||
*result++ = '.';
|
||||
int32_t decimal = abs((int32_t)((value - whole) * p[format]));
|
||||
for (int8_t i = 1; i < format; i++) {
|
||||
if (decimal < p[i]) {
|
||||
*result++ = '0'; // add leading zeros
|
||||
}
|
||||
}
|
||||
itoa(decimal, result, 10);
|
||||
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user