Format of float numbers

I sum up some values with jQuery, which automatically inserts a dot if the result is a float. However, I would like to use a comma instead, how can I do this?

I don’t know if this can be of any help, but I forgot to say that I use this function to add a dot every 3 numbers to improve readability:


function aggiungiPunti(x) {
   	return x.toString().replace(/\\B(?=(?:\\d{3})+(?!\\d))/g, ".");
}

You can convert the number to a string, and replace fullstops with commas.


var value = '12.3'.toString().replace('.', ',');

  

<script type="text/javascript">

var m = 12345678912354.23
var mm= String(m).split('.');
// alert(mm);
var n = mm[0];
// var n = 12345678912354;
var s = String(n).length;

var d = ( s % 3 == 0 ) ? (s/3) : Math.floor(s/3) + 1;

// alert(d);

var A =[];

A.length= d;
n= Number( n );
for(var i = 1; i<= d; i++) {

A[A.length-i] =  n % 1000;

n =  parseInt(  n/1000);

// alert(n);

// alert(A);

}  

var res = A.join('.');  // 12.345.678.912.354; 

//alert(res);

var h = res + "," + mm[1];

alert(h); // 12.345.678.912.354,23


</script>

Thank you guys! :slight_smile: