Apple Watch 'Round' not consistent

Hi,
I have an Apple Watch complication and the round function does not seem to be working properly.
My code is below and you will see it is not rounding properly. You will see in the picture the output has multiple 0’s before a 1 (9.80000000000001)

{{ states("sensor.outside_table_temperature")|round(1) }}

This is not limited to the Apple watch. Epsilon errors have been noted to occur in Home Assistant too.

The only guaranteed solution is to use the format() function instead of the round() function.

See this post: https://community.home-assistant.io/t/value-template-returns-wrong-results/68062/2

You want: {{ '%.2f'|format( states('sensor.outside_table_temperature')|float ) }}

Thanks, works a treat!

I’ve just noticed the same problem with format and float. Have I missed something?

:astonished:

Well that looks like a bug. format() should always work.

So definitely a bug? I am running into the same issue on the apple watch complications and can’t get around it using format().

{% set x = states('sensor.temperature_average2') | float | round(1)  %}
{{ '{:.1f}'.format(x) }}

Any news on this topic? I’m not able to round a value in any ways

I find that it works if I add text after the float part of the format, e.g. ‘%.2f F’. My theory is that something parses the text generated by the template, thinks it looks like a float, and converts it to float (with epsilon error). Appending text prevents the conversion.