Skip to content

Commit

Permalink
-Numbers that contain e should be treated as doubles
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesNK committed May 4, 2008
1 parent d88e2cf commit 5f19fd9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 12 additions & 0 deletions Src/Newtonsoft.Json.Tests/Linq/LinqToJsonTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ namespace Newtonsoft.Json.Tests.Linq
{
public class LinqToJsonTest : TestFixtureBase
{
[Test]
public void DoubleValue()
{
JArray j = JArray.Parse("[-1E+4,100.0e-2]");

double value = (double)j[0];
Assert.AreEqual(-10000d, value);

value = (double)j[1];
Assert.AreEqual(1d, value);
}

[Test]
public void Manual()
{
Expand Down
3 changes: 2 additions & 1 deletion Src/Newtonsoft.Json/JsonTextReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,8 @@ private void ParseNumber()
object numberValue;
JsonToken numberType;

if (number.IndexOf('.') == -1)
if (number.IndexOf(".", StringComparison.OrdinalIgnoreCase) == -1
&& number.IndexOf("e", StringComparison.OrdinalIgnoreCase) == -1)
{
numberValue = Convert.ToInt64(_buffer.ToString(), CultureInfo.InvariantCulture);
numberType = JsonToken.Integer;
Expand Down

0 comments on commit 5f19fd9

Please sign in to comment.