Skip to content

Instantly share code, notes, and snippets.

@ricardodantas
Last active January 3, 2016 05:59
Show Gist options
  • Select an option

  • Save ricardodantas/8419859 to your computer and use it in GitHub Desktop.

Select an option

Save ricardodantas/8419859 to your computer and use it in GitHub Desktop.
Truncar float para 2 casas sem fazer arrendodamento.
Number.prototype.toFixedDown = function(digits) {
var n = this - Math.pow(10, -digits)/2;
n += n / Math.pow(2, 53);
return n.toFixed(digits);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment