neuecc / Utf8Json

Definitely Fastest and Zero Allocation JSON Serializer for C#(NET, .NET Core, Unity, Xamarin).
MIT License
2.35k stars 266 forks source link

Decimal Point Deserialization error #187

Closed nmaarse closed 2 years ago

nmaarse commented 4 years ago

I ran into a very weird situation that a specific number results in a decimal point error.

The following test results in an assertion error for value "56.27332073976768". Message: Expected pressureResult to be 56.27332073976768, but found 5627332073976768.0. The other values work fine.

I'm using FluentAssertions and Xunit together with Utf8Json version 1.3.7

 [Theory]
    [InlineData(56.27332073976767)]
    [InlineData(56.27332073976768)]
    [InlineData(56.27332073976769)]
    public void UnexpectedDecimalPointError(double value)
    {
        var pressureJson = Utf8Json.JsonSerializer.ToJsonString(value);
        double pressureResult = Utf8Json.JsonSerializer.Deserialize<double>(pressureJson);
        pressureResult.Should().Be(value);
    }
tomsoftware commented 3 years ago

I think you are not using an "English environment" ? see fix #247