diff --git a/src/samples/iio+network/iio-magnetometer-console-and-mqtt-publish.c b/src/samples/iio+network/iio-magnetometer-console-and-mqtt-publish.c index b80c0a991..6f52427ef 100644 --- a/src/samples/iio+network/iio-magnetometer-console-and-mqtt-publish.c +++ b/src/samples/iio+network/iio-magnetometer-console-and-mqtt-publish.c @@ -411,7 +411,7 @@ scale(double *x, double *y, double *z) if (sqr_norm < MAGNETIC_LOW) sanity_norm = MAGNETIC_LOW; - if (sanity_norm && sqr_norm) { + if (fpclassify(sanity_norm) != FP_ZERO && fpclassify(sqr_norm) != FP_ZERO) { scale = sanity_norm / sqr_norm; scale = sqrt(scale); *x = *x * scale;