diff --git a/openVulkanoCpp/Base/UnitFormatter.cpp b/openVulkanoCpp/Base/UnitFormatter.cpp index 499bb26..9df8cc4 100644 --- a/openVulkanoCpp/Base/UnitFormatter.cpp +++ b/openVulkanoCpp/Base/UnitFormatter.cpp @@ -15,7 +15,17 @@ namespace std::string FormatValue(T value, int precision, bool trimTrailingZeros, const std::string& suffix) { std::ostringstream out; - out << std::fixed << std::setprecision(precision) << value; + if (precision >= 0) + { + out << std::fixed << std::setprecision(precision) << value; + } + else + { + int p = -precision; + T v = value; + while (v > 1 && p > 0) { v /= 10; p--; } + out << std::fixed << std::setprecision(p) << value; + } std::string result = out.str(); if (trimTrailingZeros && result.find('.') != std::string::npos)