Click here to Skip to main content
15,889,863 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an array with 5 position and all these with the same value 170.881.914 (without Decimals), when I debug by Firefox the values are ok, but when these come to my controller with type List<float>, the values were remplaced by 170.881.920 and I don't know why.
this is the code.

var actualizarFilaItem = JSON.stringify({
            "idProyecto": idProyecto,
            "item": itemGuardar,                //Here go the array
            "año": añoActual


var urlActualizarFilaItem = $('#urlActualizarFilaItem').val();
        $.ajax({
            url: urlActualizarFilaItem,
            type: 'POST',
            data: actualizarFilaItem,
            async: false,
            cache: false,
            dataType: 'json',
            contentType: "application/json; charset=utf-8",
            beforeSend: function () {
                showSpinner();
            },


What I have tried:

I tried to convert in all the places where appear the value to "parseFloat"
Posted
Comments
F-ES Sitecore 17-Apr-18 9:45am    
It might be a locale thing, if you're usual a locale thing where "," is getting interpreted as "." as some locales represent one million as 1,000,000 and some as 1.000.000. If you're passing comma separated numbers it might be interpreting "170,881" not as two numbers but as one hundred and seventy thousand, eight hundred and eighty one, and in the server-side local that might be "170.881".
Richard MacCutchan 17-Apr-18 17:31pm    
Probably due to the way floating point numbers are represented in memory, and how they may lose precision. Try making them doubles, which provide greater precision.

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