From 0cc3f08eecb944522ec67c30b2b9ddbdc69c31b9 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 11 May 2021 18:13:35 +0200 Subject: [PATCH] Fixed handling of exp constants in shaders --- .../SyntaxRewriters/HlslSourceRewriter.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ComputeSharp.SourceGenerators/SyntaxRewriters/HlslSourceRewriter.cs b/src/ComputeSharp.SourceGenerators/SyntaxRewriters/HlslSourceRewriter.cs index 2fae4740..b52a6974 100644 --- a/src/ComputeSharp.SourceGenerators/SyntaxRewriters/HlslSourceRewriter.cs +++ b/src/ComputeSharp.SourceGenerators/SyntaxRewriters/HlslSourceRewriter.cs @@ -180,7 +180,11 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters { string literal = updatedNode.Token.ValueText; - if (!literal.Contains('.')) literal += ".0"; + // If the numeric literal is neither a decimal nor an exponential, add the ".0" suffix + if (literal.IndexOfAny(new[] { '.', 'E' }) == -1) + { + literal += ".0"; + } return updatedNode.WithToken(Literal(literal, 0f)); }