From 5613516c5724ec9ad25b1e08d9c4d4ea1ab3f329 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 22 Apr 2021 13:57:22 +0300 Subject: [PATCH] Even better formatting of folded literals A negative value does not consist entirely of digits yet may lack a decimal point. But a point must not be added after an exponent. --- source/glsl/optimize.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/glsl/optimize.cpp b/source/glsl/optimize.cpp index ed20bb17..16e43a9e 100644 --- a/source/glsl/optimize.cpp +++ b/source/glsl/optimize.cpp @@ -646,8 +646,8 @@ void ConstantFolder::visit(RefPtr &expr) literal->token = lexical_cast(r_constant_value.value())+"u"; else if(r_constant_value.check_type()) { - literal->token = lexical_cast(r_constant_value.value()); - if(isnumrc(literal->token)) + literal->token = lexical_cast(r_constant_value.value(), Fmt().precision(8)); + if(literal->token.find('.')==string::npos && literal->token.find('e')==string::npos) literal->token += ".0"; } else -- 2.43.0