Merge pull request #23145 from savuor:backport34_fix_inf

Backport to 3.4: cvIsInf() fix
pull/23148/head
Alexander Smorkalov 2 years ago committed by GitHub
commit c664cf3717
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      modules/core/include/opencv2/core/fast_math.hpp
  2. 14
      modules/core/test/test_math.cpp

@ -295,7 +295,7 @@ CV_INLINE int cvIsInf( double value )
#elif defined(__x86_64__) || defined(_M_X64) || defined(__aarch64__) || defined(_M_ARM64) || defined(__PPC64__)
Cv64suf ieee754;
ieee754.f = value;
return (ieee754.u & 0x7fffffff00000000) ==
return (ieee754.u & 0x7fffffffffffffff) ==
0x7ff0000000000000;
#else
Cv64suf ieee754;

@ -3992,6 +3992,13 @@ TEST(Core_FastMath, InlineNaN)
EXPECT_EQ( cvIsNaN((double) NAN), 1);
EXPECT_EQ( cvIsNaN((double) -NAN), 1);
EXPECT_EQ( cvIsNaN(0.0), 0);
// Regression: check the +/-Inf cases
Cv64suf suf;
suf.u = 0x7FF0000000000000UL;
EXPECT_EQ( cvIsNaN(suf.f), 0);
suf.u = 0xFFF0000000000000UL;
EXPECT_EQ( cvIsNaN(suf.f), 0);
}
TEST(Core_FastMath, InlineIsInf)
@ -4003,6 +4010,13 @@ TEST(Core_FastMath, InlineIsInf)
EXPECT_EQ( cvIsInf((double) HUGE_VAL), 1);
EXPECT_EQ( cvIsInf((double) -HUGE_VAL), 1);
EXPECT_EQ( cvIsInf(0.0), 0);
// Regression: check the cases of 0x7FF00000xxxxxxxx
Cv64suf suf;
suf.u = 0x7FF0000000000001UL;
EXPECT_EQ( cvIsInf(suf.f), 0);
suf.u = 0x7FF0000012345678UL;
EXPECT_EQ( cvIsInf(suf.f), 0);
}
}} // namespace

Loading…
Cancel
Save