For JTokenType.Float, we should add the comparison for decimal type.
This commit is contained in:
yadoer
2017-05-28 15:18:29 +12:00
committed by James Newton-King
parent f523b2d3bc
commit b62c0286c4
2 changed files with 6 additions and 1 deletions
@@ -341,6 +341,7 @@ namespace Newtonsoft.Json.Tests.Linq
Assert.IsTrue(JToken.DeepEquals(new JValue(5L), new JValue(5)));
Assert.IsFalse(JToken.DeepEquals(new JValue(5M), new JValue(5)));
Assert.IsTrue(JToken.DeepEquals(new JValue((ulong)long.MaxValue), new JValue(long.MaxValue)));
Assert.IsFalse(JToken.DeepEquals(new JValue(0.102410241024102424m), new JValue(0.102410241024102425m)));
}
[Test]
@@ -852,4 +853,4 @@ namespace Newtonsoft.Json.Tests.Linq
}
#endif
}
}
}
+4
View File
@@ -297,6 +297,10 @@ namespace Newtonsoft.Json.Linq
return -CompareBigInteger((BigInteger)objB, objA);
}
#endif
if (objA is ulong || objB is ulong || objA is decimal || objB is decimal)
{
return Convert.ToDecimal(objA, CultureInfo.InvariantCulture).CompareTo(Convert.ToDecimal(objB, CultureInfo.InvariantCulture));
}
return CompareFloat(objA, objB);
case JTokenType.Comment:
case JTokenType.String: