Skip to content

Commit

Permalink
Improve number to canonical string formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
adams85 committed Feb 2, 2024
1 parent 1f3a0a3 commit a89ce64
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ConfigCatClient/Evaluation/RolloutEvaluator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,11 @@ private static string UserAttributeValueToString(object attributeValue)
}
else if (attributeValue.TryConvertNumericToDouble(out var number))
{
return number.ToString(CultureInfo.InvariantCulture).Replace("E", "e");
var abs = Math.Abs(number);
var format = 1e-7 < abs && abs < 1e21
? "0.#################"
: "0.#################e+0";
return number.ToString(format, CultureInfo.InvariantCulture);
}
else if (attributeValue.TryConvertDateTimeToDateTimeOffset(out var dateTimeOffset))
{
Expand Down

0 comments on commit a89ce64

Please sign in to comment.