MCPcopy Create free account
hub / github.com/alibaba/loongcollector / DoubleToString

Function DoubleToString

core/common/StringTools.cpp:437–449  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

435}
436
437std::string DoubleToString(double value) {
438 std::string result = std::to_string(value);
439 // Remove trailing zeros
440 size_t dotPos = result.find('.');
441 if (dotPos != std::string::npos) {
442 size_t lastNonZero = result.find_last_not_of('0');
443 if (lastNonZero >= dotPos) {
444 // If last non-zero char is the dot, remove it too
445 result.erase(lastNonZero == dotPos ? dotPos : lastNonZero + 1);
446 }
447 }
448 return result;
449}
450
451} // namespace logtail

Callers 2

TEST_FFunction · 0.85

Calls 1

findMethod · 0.80

Tested by 1

TEST_FFunction · 0.68