[thelist] Calculations in JS
Shashank Tripathi
sub at shanx.com
Sun Jul 21 07:35:01 CDT 2002
Correction (removed the two zeroes after decimal) ...but hope you get
the point anyway.
| // Original number truncated to 1 decimal
| var orig = 0.833333333333;
| var truncated = Math.round(orig*10)/10; // gives you 0.8
|
|
| // Original number truncated to 2 decimals
| var orig = 0.833333333333;
| var truncated = Math.round(orig*100)/100; // gives you 0.83
|
Shanx
More information about the thelist
mailing list