Last active
March 12, 2023 21:27
-
-
Save nathnolt/dda470b1b4d359905eac56ec49225b1e to your computer and use it in GitHub Desktop.
Stringifies a number with all of the precision in JavaScript
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
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