diff --git a/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp b/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp index 19cb3b3fd66b515897c538f85b85a14bc04871f0..131b839841f6acfa1a58afbf6b6ff607f7730151 100644 --- a/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp +++ b/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp @@ -461,31 +461,7 @@ static bool PerformRelationOperation(InputType left, InputType right, lexer::Tok } case lexer::TokenType::PUNCTUATOR_STRICT_EQUAL: case lexer::TokenType::PUNCTUATOR_EQUAL: { - if constexpr (std::is_same_v) { - // Compare floating point numbers in two steps: - // 1. With fixed epsilon - // 2. with adaptive epsilon - // Minimal possible difference between two float values - // For float (IEEE-754 binary32) it is 2^(-23) and its bit representation is 0x34000000. - static auto epsilon = bit_cast(FLOAT_BIT_REPRESENTATION); - if (std::fabs(left - right) <= epsilon) { - return true; - } - return std::fabs(left - right) <= epsilon * std::fmax(std::fabs(left), std::fabs(right)); - } else if constexpr (std::is_same_v) { - // Compare floating point numbers in two steps: - // 1. With fixed epsilon - // 2. with adaptive epsilon - // Minimal possible difference between two double values - // For double (IEEE-754 binary64) it is 2^(-52) and its bit representation is 0x3cb0000000000000. - static auto epsilon = bit_cast(DOUBLE_BIT_REPRESENTATION); - if (std::fabs(left - right) <= epsilon) { - return true; - } - return std::fabs(left - right) <= epsilon * std::fmax(std::fabs(left), std::fabs(right)); - } else { return left == right; - } } case lexer::TokenType::PUNCTUATOR_NOT_STRICT_EQUAL: case lexer::TokenType::PUNCTUATOR_NOT_EQUAL: { diff --git a/ets2panda/compiler/lowering/ets/constantExpressionLowering.h b/ets2panda/compiler/lowering/ets/constantExpressionLowering.h index 4b4b67b7fb69989cf3ca2043e2e56933f3c3696d..ae0645eeb31d06771336ac2d61cc74f3f19c3400 100644 --- a/ets2panda/compiler/lowering/ets/constantExpressionLowering.h +++ b/ets2panda/compiler/lowering/ets/constantExpressionLowering.h @@ -20,8 +20,6 @@ namespace ark::es2panda::compiler { -constexpr static uint64_t FLOAT_BIT_REPRESENTATION = 0x34000000; -constexpr static uint64_t DOUBLE_BIT_REPRESENTATION = 0x3cb0000000000000; constexpr static char32_t MAX_CHAR = 0xFFFF; enum class TypeRank {