From 6047bd0c383ff8b80ec71f7f20a8b7908e36cf61 Mon Sep 17 00:00:00 2001 From: caizj Date: Fri, 3 Dec 2021 17:54:13 +0800 Subject: [PATCH] Fix [WhiteScan] [FLOATING_POINT_EQUALITY] (#635) --- src/sql/engine/expr/ob_expr_sqrt.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sql/engine/expr/ob_expr_sqrt.cpp b/src/sql/engine/expr/ob_expr_sqrt.cpp index 9c646fd157..d2546f6a79 100644 --- a/src/sql/engine/expr/ob_expr_sqrt.cpp +++ b/src/sql/engine/expr/ob_expr_sqrt.cpp @@ -74,7 +74,7 @@ int ObExprSqrt::calc_result1(ObObj& result, const ObObj& obj, ObExprCtx& expr_ct double value = obj.get_double(); if (value < 0) { ret = OB_ERR_ARGUMENT_OUT_OF_RANGE; - } else if (value == -0) { + } else if (std::fpclassify(value) == FP_ZERO) { result.set_double(-0); } else { result.set_double(sqrt(value)); @@ -83,7 +83,7 @@ int ObExprSqrt::calc_result1(ObObj& result, const ObObj& obj, ObExprCtx& expr_ct float value = obj.get_float(); if (value < 0) { ret = OB_ERR_ARGUMENT_OUT_OF_RANGE; - } else if (value == -0) { + } else if (std::fpclassify(value) == FP_ZERO) { result.set_float(-0); } else { result.set_float(sqrtf(value)); -- GitLab