ShawnJ434
08-10-2003, 09:19 PM
I did a math calculation and I'm getting way to many decimal points.How do I limit to two decimal places to the right of the decimal point?
|
Click to See Complete Forum and Search --> : decimal points ShawnJ434 08-10-2003, 09:19 PM I did a math calculation and I'm getting way to many decimal points.How do I limit to two decimal places to the right of the decimal point? ShawnJ434 08-10-2003, 09:32 PM Nevermind I figured it out. USER4FUN 10-16-2006, 01:59 PM it would be nice if you share the solution so other people that look for it would find it Kravvitz 10-16-2006, 03:12 PM He probably used toFixed(). This is to add support for it to older browsers: if(typeof(Number)!='undefined'&&typeof(Number.prototype)!='undefined'){ if(typeof(Number.prototype.toFixed)=='undefined'){ // for IE versions older than 5.5 and Netscape 4.x. Early versions of NS4.x // don't support ===, so I used == and typeof() to simulate it. Number.prototype.toFixed=function(d){ var n=this; d=(d||((d==0)&&(typeof(d)=='number')))?d:2; var f=Math.pow(10,d); n=((Math.round(n*f)/f)+Math.pow(10,-(d+1)))+''; return n.substring(0,(d==0)?n.indexOf('.'):n.indexOf('.')+d+1); } } } webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |