Error in displaying temperature

Alf-DK2 years ago

I have a couple of trackers with DS18B20 sensors on and they work fine, but sometimes Traccar shows a lot of zeros like this 22.400000000000002 ° C instead of 22.4 ° C
What could be wrong ?

Anton Tananaev2 years ago

It probably result of some operation. Check this for more details on why it happens:

https://en.wikipedia.org/wiki/Floating-point_arithmetic#Accuracy_problems

Alf-DK2 years ago

yes ok.
Is it possible to make so traccar only shows a decimal after the comma no matter what. ?

Anton Tananaev2 years ago

Use computed attributes to round the number.

Alf-DK2 years ago

thought i could do it in there i was just not sure.

I currently have her expression as a string (temp0 + "° C")

Alf-DK2 years ago

is there anyone who will help me a little here?
Have tried with a lot of google searches but can not make it work!

i do not know how to write it in the, expression field

have tried with round (2) and toFixed (2), but how should it be written in expression ???