Skip to content

Instantly share code, notes, and snippets.

@jocoonopa
Created November 19, 2013 08:44
Show Gist options
  • Save jocoonopa/7542238 to your computer and use it in GitHub Desktop.
Save jocoonopa/7542238 to your computer and use it in GitHub Desktop.
Math.formatFloat = function (f, digit) {
var m = Math.pow( 10, digit);
return parseInt(f * m, 10) / m;
}
var numA = 0.1;
var numB = 0.2;
alert(Math.formatFloat( numA + numB, 1) === 0.3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment