diff --git a/src/Microsoft.OData.Core/UriParser/ExpressionLexer.cs b/src/Microsoft.OData.Core/UriParser/ExpressionLexer.cs index 74268ae2a1..8a1c4d81a0 100644 --- a/src/Microsoft.OData.Core/UriParser/ExpressionLexer.cs +++ b/src/Microsoft.OData.Core/UriParser/ExpressionLexer.cs @@ -1057,11 +1057,11 @@ private static ExpressionTokenKind MakeBestGuessOnNoSuffixStr(string numericStr, decimal doubleToDecimalR; decimal doubleToDecimalN; - // To keep the full presion of the current value, which if necessary is all 17 digits of precision supported by the Double type. - bool doubleCanBeDecimalR = decimal.TryParse(tmpDouble.ToString("R", CultureInfo.InvariantCulture), NumberStyles.Integer | NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out doubleToDecimalR); + // To keep the full precision of the current value, which if necessary is all 17 digits of precision supported by the Double type. + bool doubleCanBeDecimalR = decimal.TryParse(tmpDouble.ToString("R", CultureInfo.InvariantCulture), NumberStyles.Float, CultureInfo.InvariantCulture, out doubleToDecimalR); // To cover the scientific notation case, such as 1e+19 in the tmpDouble - bool doubleCanBeDecimalN = decimal.TryParse(tmpDouble.ToString("N29", CultureInfo.InvariantCulture), NumberStyles.Integer | NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out doubleToDecimalN); + bool doubleCanBeDecimalN = decimal.TryParse(tmpDouble.ToString("N29", CultureInfo.InvariantCulture), NumberStyles.Number, CultureInfo.InvariantCulture, out doubleToDecimalN); if ((doubleCanBeDecimalR && doubleToDecimalR != tmpDecimal) || (!doubleCanBeDecimalR && doubleCanBeDecimalN && doubleToDecimalN != tmpDecimal)) {