Format Long Numbers

[Total: 0    Average: 0/5]

This will format numbers to have commas in it.

Body Code:

<script>
/*
 * Mod by: devendrags@mumbainet.com
 * Date: July, 2004
 */
function convert(_a)
{
 var _b=_a.toString().split("");
 var _c="";
 var _d=0;
 for(var i=_b.length-1;i>=0;i--)
 {
   _d++;
   _c=_b[i]+_c;
   if(_d%3==0&&i!=0-1&& _b.length != _d)
   {
   _c=","+_c;
   }
 }
 return(_c);
}
var A=1234567890;
var B=convert(A);
document.write("A="+A+"<BR>B="+B);
</script>

Times Viewed: 2

Leave a Reply

Your email address will not be published. Required fields are marked *