Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangstar333 committed Jan 17, 2025
1 parent 6975cbb commit 487e852
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions be/src/vec/functions/function_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,16 @@ class FunctionFormatNumber : public IFunction {
fmt::format_to(buffer, "-");
}
if (abs_number == 1) {
//eg: 1000 ---> 1K
fmt::format_to(buffer, "{}", abs_number);
} else if (abs_number < 10) {
//eg: 1239 ---> 1.24K only want to show 2 decimal
fmt::format_to(buffer, "{:.2f}", abs_number);
} else if (abs_number < 100) {
//eg: 12399999 ---> 12.4M only want to show 1 decimal
fmt::format_to(buffer, "{:.1f}", abs_number);
} else {
// eg: 999999999999999 ---> 1000T only want to show 0 decimal
fmt::format_to(buffer, "{:.0f}", abs_number);
}
fmt::format_to(buffer, UNITS[unit_index]);
Expand Down

0 comments on commit 487e852

Please sign in to comment.