Skip to content

Commit

Permalink
fix(wechat_code): Modify isnan implementation for compatibility wit…
Browse files Browse the repository at this point in the history
…h -ffast_math.

fix opencv#3150
  • Loading branch information
Konano committed May 10, 2023
1 parent 3a2ed1c commit 21e1846
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions modules/wechat_qrcode/src/zxing/zxing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,14 @@ typedef unsigned char boolean;
#include <cmath>

namespace zxing {
inline bool isnan(float v) { return std::isnan(v); }
inline bool isnan(double v) { return std::isnan(v); }
inline bool isnan(float v) {
union { float v; uint32_t x; } u = { v };
return (u.x & 0x7fffffffu) > 0x7f800000u;
}
inline bool isnan(double v) {
union { double v; uint64_t x; } u = { v };
return (u.x & ~0x8000000000000000uLL) > 0x7ff0000000000000uLL;
}
inline float nan() { return std::numeric_limits<float>::quiet_NaN(); }
} // namespace zxing

Expand Down

0 comments on commit 21e1846

Please sign in to comment.