Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Biohazrd.CSharp/CSharpLibraryGenerator.Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ static bool IsBooleanType(VisitorContext context, TypeReference targetType)
// https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings#the-round-trip-r-format-specifier
// The explicit d suffix is not commonly used, but it makes a double constant without the a decimal point.
// https://github.com/dotnet/csharplang/blob/8e7d390f6deaec0a01f690f9689ebf93903f4b00/spec/lexical-structure.md#real-literals
return $"{value:G17}d";
return $"{value.ToString("G17", System.Globalization.CultureInfo.InvariantCulture)}d";
}
}
case FloatConstant floatConstant:
Expand Down Expand Up @@ -116,7 +116,7 @@ static bool IsBooleanType(VisitorContext context, TypeReference targetType)
Debug.Assert(float.IsFinite(value), $"The float must be finite at this point!");
// G9 is the recommended format specifier for round-trippable floats
// https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings#the-round-trip-r-format-specifier
return $"{value:G9}f";
return $"{value.ToString("G9", System.Globalization.CultureInfo.InvariantCulture)}f";
}
}
case StringConstant stringConstant:
Expand Down
6 changes: 4 additions & 2 deletions Biohazrd/Expressions/DoubleConstant.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Biohazrd.Expressions
using System.Globalization;

namespace Biohazrd.Expressions
{
public sealed record DoubleConstant : ConstantValue
{
Expand All @@ -8,6 +10,6 @@ public DoubleConstant(double value)
=> Value = value;

public override string ToString()
=> Value.ToString("G17");
=> Value.ToString("G17", CultureInfo.InvariantCulture);
}
}
6 changes: 4 additions & 2 deletions Biohazrd/Expressions/FloatConstant.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Biohazrd.Expressions
using System.Globalization;

namespace Biohazrd.Expressions
{
public sealed record FloatConstant : ConstantValue
{
Expand All @@ -8,6 +10,6 @@ public FloatConstant(float value)
=> Value = value;

public override string ToString()
=> Value.ToString("G9");
=> Value.ToString("G9", CultureInfo.InvariantCulture);
}
}