Merge branch 'pr/166' into Radiosonde-vaisala-add-temp-humidity-merge-conflicts-fix

This commit is contained in:
Erwin Ried 2020-09-14 23:11:08 +02:00
commit 3d9ce8a037
8 changed files with 247 additions and 74 deletions

View file

@ -223,3 +223,13 @@ std::string unit_auto_scale(double n, const uint32_t base_nano, uint32_t precisi
return string;
}
double get_decimals(double num, int16_t mult, bool round) {
num -= int(num); //keep decimals only
num *= mult; //Shift decimals into integers
if (!round) return num;
int16_t intnum = int(num); //Round it up if necessary
num -= intnum; //Get decimal part
if (num > .5) intnum++; //Round up
return intnum;
}