]> sigrok.org Git - libsigrok.git/commitdiff
dtm0660: Do not apply the exponent twice on the value
authorAdrian Stratulat <redacted>
Fri, 15 Jun 2018 13:39:15 +0000 (16:39 +0300)
committerUwe Hermann <redacted>
Mon, 18 Jun 2018 13:26:46 +0000 (15:26 +0200)
This fixes bug #1236.

src/dmm/dtm0660.c

index 86b6ccf7df2e6422ae60c17df3801d236a3f4d7f..42012399e22195a2b3ee10e1f5dcfe4f7cfc642f 100644 (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) {