diff options
Diffstat (limited to 'src/support/safe_integer.cpp')
-rw-r--r-- | src/support/safe_integer.cpp | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/support/safe_integer.cpp b/src/support/safe_integer.cpp index ca5052cd2..23ef84b22 100644 --- a/src/support/safe_integer.cpp +++ b/src/support/safe_integer.cpp @@ -35,17 +35,18 @@ bool wasm::isSInteger32(double x) { } uint32_t wasm::toUInteger32(double x) { - return std::signbit(x) ? 0 : (x < std::numeric_limits<uint32_t>::max() - ? (uint32_t)x - : std::numeric_limits<uint32_t>::max()); + return std::signbit(x) ? 0 + : (x < std::numeric_limits<uint32_t>::max() + ? (uint32_t)x + : std::numeric_limits<uint32_t>::max()); } int32_t wasm::toSInteger32(double x) { return (x > std::numeric_limits<int32_t>::min() && x < std::numeric_limits<int32_t>::max()) - ? (int32_t)x - : (std::signbit(x) ? std::numeric_limits<int32_t>::min() - : std::numeric_limits<int32_t>::max()); + ? (int32_t)x + : (std::signbit(x) ? std::numeric_limits<int32_t>::min() + : std::numeric_limits<int32_t>::max()); } bool wasm::isUInteger64(double x) { @@ -59,17 +60,18 @@ bool wasm::isSInteger64(double x) { } uint64_t wasm::toUInteger64(double x) { - return std::signbit(x) ? 0 : (x < (double)std::numeric_limits<uint64_t>::max() - ? (uint64_t)x - : std::numeric_limits<uint64_t>::max()); + return std::signbit(x) ? 0 + : (x < (double)std::numeric_limits<uint64_t>::max() + ? (uint64_t)x + : std::numeric_limits<uint64_t>::max()); } int64_t wasm::toSInteger64(double x) { return (x > (double)std::numeric_limits<int64_t>::min() && x < (double)std::numeric_limits<int64_t>::max()) - ? (int64_t)x - : (std::signbit(x) ? std::numeric_limits<int64_t>::min() - : std::numeric_limits<int64_t>::max()); + ? (int64_t)x + : (std::signbit(x) ? std::numeric_limits<int64_t>::min() + : std::numeric_limits<int64_t>::max()); } /* 3 32222222 222...00 @@ -116,6 +118,7 @@ bool wasm::isInRangeI64TruncU(int32_t i) { return (u < 0x5f800000U) || (u >= 0x80000000U && u < 0xbf800000U); } +/* clang-format off */ /* * 6 66655555555 5544...222221...000 * 3 21098765432 1098...432109...210 @@ -139,6 +142,7 @@ bool wasm::isInRangeI64TruncU(int32_t i) { * 1 11111111111 0000...000000...001 0xfff0000000000001 => -nan(0x1) * 1 11111111111 1111...111111...111 0xffffffffffffffff => -nan(0xfff...) */ +/* clang-format on */ bool wasm::isInRangeI32TruncS(int64_t i) { uint64_t u = i; |