CayenneLPP icon indicating copy to clipboard operation
CayenneLPP copied to clipboard

Enhancement: "businesslike conduct" round to reduce data error from 0.09 to 0.05 (~50% accuracy enhancement)

Open g6094199 opened this issue 1 year ago • 0 comments

hi,

we have seen some problems when it comes to rounding (in our case for temp measurements).

in the current code the float temp just gets cut after the 1st decimal place, which is very inaccurate!

float celsius; int16_t val = celsius * 10;

in this case the error is at worst 0.09. almost 0.1° off.

instead the float temp should be businesslike conduct rounded (in germany we call this "Kaufmännisches Runden") before chopping off the last diget, like so:

float celsius; int16_t val = round(celsius * 10);

in this case the error is @ max. 0.05° off. which is much more accurate for professional use. of cause other values can benefit from this kind of correction, too.

g6094199 avatar Jun 12 '23 13:06 g6094199