Skip to content

Instantly share code, notes, and snippets.

@NKid

NKid/trick.js Secret

Last active August 19, 2020 10:06
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 NKid/7a63550526ffb475b06c to your computer and use it in GitHub Desktop.
Save NKid/7a63550526ffb475b06c to your computer and use it in GitHub Desktop.
0.1+0.2 != 0.3
var num = 0.1 + 0.2; // 0.30000000000000004
console.log(num == 0.3); // false
console.log(num); // 0.30000000000000004
console.log(num.toFixed()); // "0"
console.log(num.toFixed(1)); // "0.3"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment