|
||
| Inside Technique : Fix() Method This adds a fix method to the JavaScript number object. The fix() method returns the number rounded to the specified number of digits. For example, Number.fix() Method Code
function _fix(dig) {
// dig specifies how many digits
// Invalid values default to 0.
if ((dig<0) || (dig==null) || (isNaN(dig))) dig=0
var power = Math.pow(10,dig)
return Math.round(this.valueOf()*power)/power;
}
Number.prototype.fix = _fix
© 1997-2000 InsideDHTML.com, LLC. All rights reserved. |