Created
November 14, 2014 10:12
-
-
Save gsingharoy/2873710f69daa2100a2f to your computer and use it in GitHub Desktop.
Gets a short description of long numbers with a suffix. eg, 1931200 will become 192.1K
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
//Gets a short description of long numbers with a suffix. eg, 1931200 will become 192.1K | |
function get_long_number_display(long_number){ | |
if(long_number/1000000000 > 1) | |
return (Number((long_number/1000000000).toFixed(1))).toString()+"B"; //in billions | |
else if(long_number/1000000 > 1) | |
return (Number((long_number/1000000).toFixed(1))).toString()+"M"; //in millions | |
else if(long_number/1000 > 1) | |
return (Number((long_number/1000).toFixed(1))).toString()+"K"; //in thousands | |
else | |
return long_number.toString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment