dtm0660: Do not apply the exponent twice on the value

This fixes bug #1236.
This commit is contained in:
Adrian Stratulat 2018-06-15 16:39:15 +03:00 committed by Uwe Hermann
parent 10481ef05d
commit b8fcae5a12
1 changed files with 3 additions and 1 deletions

View File

@ -254,6 +254,8 @@ static void parse_flags(const uint8_t *buf, struct dtm0660_info *info)
static void handle_flags(struct sr_datafeed_analog *analog, float *floatval,
int *exponent, const struct dtm0660_info *info)
{
int initial_exponent = *exponent;
/* Factors */
if (info->is_nano)
*exponent -= 9;
@ -265,7 +267,7 @@ static void handle_flags(struct sr_datafeed_analog *analog, float *floatval,
*exponent += 3;
if (info->is_mega)
*exponent += 6;
*floatval *= powf(10, *exponent);
*floatval *= powf(10, (*exponent - initial_exponent));
/* Measurement modes */
if (info->is_volt) {