diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-05-11 10:26:50 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-06-25 10:19:09 +0200 |
commit | a418fd5cbbf2d121c93d27194c02eb36aa4ac97e (patch) | |
tree | 2839c20b8ddcc420528181b55e4a856315a83418 /src/corelib/global | |
parent | e721ec269e972ea2754cb9bd27fb73b72ed53c7b (diff) |
Improve casting
Make a handful of narrowing casts explicit
Change-Id: I318e9778840f2437963377b6b97f269d569909dc
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Diffstat (limited to 'src/corelib/global')
-rw-r--r-- | src/corelib/global/qfloat16.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/corelib/global/qfloat16.h b/src/corelib/global/qfloat16.h index a25130958f..9ac811a3e6 100644 --- a/src/corelib/global/qfloat16.h +++ b/src/corelib/global/qfloat16.h @@ -72,7 +72,7 @@ class qfloat16 // To let our private constructor work, without other code seeing // ambiguity when constructing from int, double &c. quint16 b16; - constexpr inline explicit Wrap(int value) : b16(value) {} + constexpr inline explicit Wrap(int value) : b16(quint16(value)) {} }; public: constexpr inline qfloat16() noexcept : b16(0) {} @@ -172,8 +172,8 @@ inline qfloat16::qfloat16(float f) noexcept #else quint32 u; memcpy(&u, &f, sizeof(quint32)); - b16 = basetable[(u >> 23) & 0x1ff] - + ((u & 0x007fffff) >> shifttable[(u >> 23) & 0x1ff]); + b16 = quint16(basetable[(u >> 23) & 0x1ff] + + ((u & 0x007fffff) >> shifttable[(u >> 23) & 0x1ff])); #endif } QT_WARNING_POP @@ -268,8 +268,8 @@ QF16_MAKE_BOOL_OP(float) #undef QF16_MAKE_BOOL_OP_FP #define QF16_MAKE_BOOL_OP_INT(OP) \ - inline bool operator OP(qfloat16 a, int b) noexcept { return static_cast<float>(a) OP b; } \ - inline bool operator OP(int a, qfloat16 b) noexcept { return a OP static_cast<float>(b); } + inline bool operator OP(qfloat16 a, int b) noexcept { return static_cast<float>(a) OP static_cast<float>(b); } \ + inline bool operator OP(int a, qfloat16 b) noexcept { return static_cast<float>(a) OP static_cast<float>(b); } QF16_MAKE_BOOL_OP_INT(>) QF16_MAKE_BOOL_OP_INT(<) QF16_MAKE_BOOL_OP_INT(>=) |