Skip to content

Commit

Permalink
rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
felixwluo committed Jul 11, 2024
1 parent 4173079 commit 60c409c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions be/src/olap/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,8 @@ bool valid_decimal(const std::string& value_str, const uint32_t precision, const
}

size_t number_length = value_str.size();
if (value_str[0] == '-') {
bool is_negative = value_str[0] == '-';
if (is_negative) {
--number_length;
}

Expand All @@ -557,11 +558,11 @@ bool valid_decimal(const std::string& value_str, const uint32_t precision, const
integer_len = number_length;
fractional_len = 0;
} else {
integer_len = point_pos;
integer_len = point_pos - (is_negative ? 1 : 0);
fractional_len = number_length - point_pos - 1;
}

if ((integer_len + fractional_len) <= precision && fractional_len <= frac) {
if (integer_len <= (precision - frac) && fractional_len <= frac) {
return true;
} else {
return false;
Expand Down

0 comments on commit 60c409c

Please sign in to comment.