From 6fd1c5b4bfae9563f3e2ecf17e07c0812e5ebc59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20=C4=8Cerm=C3=A1k?= Date: Mon, 17 Sep 2018 09:24:29 +0200 Subject: [PATCH] [types] Fix check for finite numbers on Linux On Linux we were merely checking whether f is finite, but that does not cover the case f=NaN. => use isfinite instead which checks whether f != inf && f != NaN --- src/types.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/types.cpp b/src/types.cpp index cb3df1f5..53bfae80 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -674,11 +674,10 @@ namespace Exiv2 { Rational floatToRationalCast(float f) { #if defined(_MSC_VER) && _MSC_VER < 1800 - #define isinf(x) (!_finite(x)) -#elif __APPLE__ - #define isinf(x) (isinf(x) || isnan(x)) + if (!_finite(f)) { +#else + if (!std::isfinite(f)) { #endif - if (isinf(f)) { return Rational(f > 0 ? 1 : -1, 0); } // Beware: primitive conversion algorithm