Skip to content

Instantly share code, notes, and snippets.

@nachodd
Created October 4, 2013 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nachodd/6830582 to your computer and use it in GitHub Desktop.
Save nachodd/6830582 to your computer and use it in GitHub Desktop.
Extends the Number object, adding a method to fix down some value. Extiende al objeto Number, añadiendo un metodo para redondear para abajo un valor.
Number.prototype.toFixedDown = function(digits) {
var n = this - Math.pow(10, -digits)/2;
n += n / Math.pow(2, 53); // added 1360765523: 17.56.toFixedDown(2) === "17.56"
return n.toFixed(digits);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment