Skip to content

Instantly share code, notes, and snippets.

@ryanguill
Forked from adamcameron/testRig.cfm
Last active December 31, 2015 08:19
Show Gist options
  • Save ryanguill/7959682 to your computer and use it in GitHub Desktop.
Save ryanguill/7959682 to your computer and use it in GitHub Desktop.
<cfscript>
testNumbers = [
"0", "0.0", "0.00", "0.000", "0.001",
"0.1", "0.10", "0.100", "0.101",
"0.11", "0.110", "0.111"
];
function formatter(n){
n = int(n * 100) / 100;
if ( n - int(n) > 0 ) {
return NumberFormat(n,"0.9");
}
return NumberFormat(n,"0");
}
for (testNumber in testNumbers){
writeOutput("#testNumber#: #formatter(testNumber)#<br>");
}
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment