Skip to content

Instantly share code, notes, and snippets.

@nathnolt
Last active March 12, 2023 21:27
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 nathnolt/dda470b1b4d359905eac56ec49225b1e to your computer and use it in GitHub Desktop.
Save nathnolt/dda470b1b4d359905eac56ec49225b1e to your computer and use it in GitHub Desktop.
Stringifies a number with all of the precision in JavaScript
function printFullFloat(number) {
var numStr = number.toFixed(100)
var index = numStr.length-1
var char = numStr.charAt(index)
while(char == '0') {
index--
char = numStr.charAt(index)
}
if(char != '.') {
index++
}
return numStr.substring(0, index)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment