Allow more decimal places for float slider
Closed this issue · 6 comments
Hi,
I just encountered problem when using float sliders - the most precision defaults to 4 - I can change that in .json settings - which is fine, but the problem is that no more than 4 decimal places will be displayed. I am using the GUI for GPS coordinates and ideally I need 6 decimal places for float.
You shouldn't be editing the json save files, this can introduce weird errors, you should let the library create valid jsons.
There are some problems with higher decimal precision in sliders, namely that the value starts acting unpredictably, I don't remember the exact problems with it too well but 4 decimals is a good general trade-off where I could get reasonable precision with predictable interactive value changes when interacting with the slider and avoid the float display switching to scientific notation which I definitely don't want in the sliders.
GPS coordinates are not float
values usually anyway, they're double
or higher precision to get accurate 5+ decimals
Your problem might be solved by displaying and editing the GPS coordinates as text, which doesn't have these limitations and you can then parse that text as a double
Ok, so I'm thinking it should be possible for the library user to set a higher precision than 4 decimals if they know they can deal with some slightly weird behavior in the sliders, but I'd probably keep the default 4 digits. This will require some testing to ensure it's not generating more problems than it solves, I'll take a look at it in the following weeks.
I guess the slider could actually use a double internally - that should help with weird behavior at the limits of what it can represent and also hopefully avoid scientific notation with more decimals.
BigDecimal could be perfect for this, no rounding errors, arbitrary precision. But it would be a bigger change.
Alright, I changed the internal representation of a slider value from float to double and increased the allowed precision up to 7 decimal places because it starts to act wonky at 8. It seems to work, I'll test it for a while and deploy it to production in v1.8.3 this week.
This is now live in v1.8.3 and you're welcome to try it out - the slider precision maximum has been increased from 4 decimals to 8.