Click here to Skip to main content
15,885,883 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hey guys

i little english, sorry :)

my sample code is that (it is asp.net mvc)

model.cs

C#
public class TestModel
{
    public string Name { get; set; }
    public Int64 Value { get; set; }
}


controller.cs

C#
public ActionResult Test()
{
     TestModel model = new TestModel { Name = "Test", Value = 1000000000000000001 };

     return Json(model, JsonRequestBehavior.AllowGet);
}


view.cshtml

XML
<script type="text/javascript">
    $(function () {
        $.ajax({
            type: 'GET',
            url: "/Test/Test",
            data: {},
        }).done(function (result) {
            alert(JSON.stringify(result));
        });
    });
</script>


but alert result returns {"Name":"Test","Value":1000000000000000000}

the "Value" return 1000000000000000000 (source value is 1000000000000000001)

can you tell me solution?

thanks.
Posted
Updated 13-Jul-15 1:56am
v2

1 solution

Javascript doesn't have a 64-bit integer type. Numbers will be represented by the Number type[^], which is a 64-bit double precision floating-point type.

The largest integer that the Number type can store is 9007199254740992; anything larger than that will lose precision.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900