Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Commit

Permalink
Fix dangerous floating point comparison.
Browse files Browse the repository at this point in the history
Signed-off-by: Gustavo Lima Chaves <[email protected]>
  • Loading branch information
Gustavo Lima Chaves committed Jun 8, 2017
1 parent e234b35 commit 68f825b
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 68f825b

Please sign in to comment.