How to define the number of decimal places in the settings for a Float?

Hi there!

I'm developing a datafield where the user can set their Efficiency Threshold in the settings as Float with precicion=2.

When - for example - set 0.80 then it's accepted and stored. But when I visit the settings afterwards, the value is shown as float with many decimal places which do not exactly match the given value.

Can I set the precision for settings floats?

Here are the basics in my code:

<property id="_efThreshold" type="Float">0.8</property>

<setting propertyKey="@Properties._efThreshold" title="@Strings.efThreshold">
<settingConfig type = "numeric" min = "0.5" max = "5.0" required = "true" />
</setting>

And here is a screenshot of my Connect IQ mobile app:

  • 32 bit floats are kind of odd. in that not all values can be saved in 32 bits so some may be displayed a bit oddly

  • either use fixed points (i.e use Number, and save the value *100) or save it as a string. Though I suspect that if you eventually convert it to Float, then you'll probably have the same problem. You could maybe do the whole math in fixed point though.

  • 32 bit floats are kind of odd. in that not all values can be saved in 32 bits so some may be displayed a bit oddly

    This isn't unique to 32-bit floats at all, but it's a characteristic of all floating-point numbers, including 64-bit double-precision floating-point numbers (Double in Monkey C)..

    For example, js uses 64-bit floats for its Number data type:

    > 10.8/100
    0.10800000000000001

    It would be fair to say that the problem is even more pronounced with 32-bit floats vs 64-bit floats though.