Value of a float is being truncated when passed to addConfigFloat #274

Closed
opened 2025-03-12 19:40:02 +00:00 by nconner-06 · 2 comments
nconner-06 commented 2025-03-12 19:40:02 +00:00 (Migrated from github.com)

It looks like if you define a variable as float and give it a value like this
float m_log_id = 34.65432;

Then you store the value using the addConfigFloat
config.addConfigFloat("WeatherWidget", "openWeatherLong", &m_long_id, t_openWeatherLong);

When you access the field in the web interface and afterwards in the application, it has been shorten to just 2 decimal places, so "34.65".

Can the addConfigFloat be changed to keep all the decimal places?

Thanks

It looks like if you define a variable as float and give it a value like this float m_log_id = 34.65432; Then you store the value using the addConfigFloat config.addConfigFloat("WeatherWidget", "openWeatherLong", &m_long_id, t_openWeatherLong); When you access the field in the web interface and afterwards in the application, it has been shorten to just 2 decimal places, so "34.65". Can the addConfigFloat be changed to keep all the decimal places? Thanks
nconner-06 commented 2025-03-14 20:09:28 +00:00 (Migrated from github.com)

I think I've found the issue...
In "WifiManagerCustomParameters.h", the float is converted to a string on line 112, this gives a default 2 decimal places..

Thus need to modify the line to this:
init(id, placeholder, String(value, 4).c_str(), length, "", WFM_LABEL_BEFORE);

To have 4 decimal places

I think I've found the issue... In "WifiManagerCustomParameters.h", the float is converted to a string on line 112, this gives a default 2 decimal places.. Thus need to modify the line to this: init(id, placeholder, String(value, 4).c_str(), length, "", WFM_LABEL_BEFORE); To have 4 decimal places
nconner-06 commented 2025-03-16 21:07:54 +00:00 (Migrated from github.com)

merged into the DEV branch as part of PR #281

merged into the DEV branch as part of PR #281
Sign in to join this conversation.
No description provided.