Skip to content

Latest commit

 

History

History
27 lines (24 loc) · 719 Bytes

FloatPrecision.md

File metadata and controls

27 lines (24 loc) · 719 Bytes

Float Precision

Controls how many decimal points to use when serializing floats and doubles.

[Fact]
public void FloatPrecision()
{
    var numbers = new List<object>
    {
        1.1234567f,
        1.1234567d,
    };

    var json = JsonConvert.SerializeObject(
        numbers,
        new JsonSerializerSettings
        {
            FloatPrecision = 3
        });
    Assert.Equal("[1.123,1.123]", json);
}

snippet source | anchor