From: Mikko Rasa Date: Thu, 22 Apr 2021 10:57:22 +0000 (+0300) Subject: Even better formatting of folded literals X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=5613516c5724ec9ad25b1e08d9c4d4ea1ab3f329;p=libs%2Fgl.git 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. --- 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