Created
October 4, 2013 18:38
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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