From 582ebe831204558d9113b13c38fde2a4f75d678b Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Mon, 6 Jul 2020 15:24:39 +0300 Subject: [PATCH 1/2] more efficient isInteger util --- src/support/safe_integer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/support/safe_integer.cpp b/src/support/safe_integer.cpp index 23ef84b22b2..9f45bad2e10 100644 --- a/src/support/safe_integer.cpp +++ b/src/support/safe_integer.cpp @@ -22,7 +22,7 @@ using namespace wasm; -bool wasm::isInteger(double x) { return fmod(x, 1) == 0; } +bool wasm::isInteger(double x) { return std::isfinite(x) && trunc(x) == x; } bool wasm::isUInteger32(double x) { return !std::signbit(x) && isInteger(x) && From e36c100c70050aee8246dc946b28e1bfade1f3fe Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Mon, 6 Jul 2020 15:56:47 +0300 Subject: [PATCH 2/2] refactor --- src/support/safe_integer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/support/safe_integer.cpp b/src/support/safe_integer.cpp index 9f45bad2e10..d43f7a6aa30 100644 --- a/src/support/safe_integer.cpp +++ b/src/support/safe_integer.cpp @@ -22,7 +22,7 @@ using namespace wasm; -bool wasm::isInteger(double x) { return std::isfinite(x) && trunc(x) == x; } +bool wasm::isInteger(double x) { return trunc(x) == x && !std::isinf(x); } bool wasm::isUInteger32(double x) { return !std::signbit(x) && isInteger(x) &&