The problem is that when I reach the value 16777216 the sum cannot go further, and is locked at this value.
I'm using ESP32-WROOM-32D and ESP-IDF 5.2.1.
An example code to reproduce the problem could be:
Code: Select all
float test = 0.0f;
int i = 0;
while (test < 123456789.0f)
{
test += 0.8f;
if (++i > 100000)
{
ESP_LOGI(TAG, "test=%0.2f", test);
i = 0;
}
}
It's very strange, if you change the line test += 0.8f; the sum gets stuck in other values.
If I load a value like 123456890.0f into the float variable, it will represent something like 123456792.0f, which I'm okay with. Why when I make successive sums the float variable can't exceed the value 16777216?
Is it some hardware configuration or some limitation of the ESP32 or am I forgetting some understanding about the floating point representation?