[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
v0.27.3
Dan Čermák 7 years ago
parent c5d46ac440
commit 6fd1c5b4bf

@ -674,11 +674,10 @@ namespace Exiv2 {
Rational floatToRationalCast(float f) Rational floatToRationalCast(float f)
{ {
#if defined(_MSC_VER) && _MSC_VER < 1800 #if defined(_MSC_VER) && _MSC_VER < 1800
#define isinf(x) (!_finite(x)) if (!_finite(f)) {
#elif __APPLE__ #else
#define isinf(x) (isinf(x) || isnan(x)) if (!std::isfinite(f)) {
#endif #endif
if (isinf(f)) {
return Rational(f > 0 ? 1 : -1, 0); return Rational(f > 0 ? 1 : -1, 0);
} }
// Beware: primitive conversion algorithm // Beware: primitive conversion algorithm

Loading…
Cancel
Save