Skip to content

Commit 21e1846

Browse files
authored
fix(wechat_code): Modify isnan implementation for compatibility with -ffast_math.
fix opencv#3150
1 parent 3a2ed1c commit 21e1846

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

modules/wechat_qrcode/src/zxing/zxing.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,14 @@ typedef unsigned char boolean;
5454
#include <cmath>
5555

5656
namespace zxing {
57-
inline bool isnan(float v) { return std::isnan(v); }
58-
inline bool isnan(double v) { return std::isnan(v); }
57+
inline bool isnan(float v) {
58+
union { float v; uint32_t x; } u = { v };
59+
return (u.x & 0x7fffffffu) > 0x7f800000u;
60+
}
61+
inline bool isnan(double v) {
62+
union { double v; uint64_t x; } u = { v };
63+
return (u.x & ~0x8000000000000000uLL) > 0x7ff0000000000000uLL;
64+
}
5965
inline float nan() { return std::numeric_limits<float>::quiet_NaN(); }
6066
} // namespace zxing
6167

0 commit comments

Comments
 (0)