Created
August 6, 2012 19:40
-
-
Save orangexception/3277875 to your computer and use it in GitHub Desktop.
CTXNumberFormat
This file contains hidden or 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 CTXNumberFormat( dNumber ) { | |
dNumber= DecimalFormat( dNumber ); | |
dNumber= dNumber.ReplaceAll( "(\.0+|\.(\d)0)$" , ".$2" ); | |
dNumber= dNumber.ReplaceAll( "," , "" ); | |
dNumber= dNumber.ReplaceAll( "\.$" , "" ); | |
dNumber= dNumber.ReplaceAll( "^0+" , "" ); | |
return dNumber; | |
} |
4+ digit numbers were including commas. I added a line to remove those as well.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
CTX Format requires that needless 0's, including leading 0's, and decimal places are removed.
Examples {input} becomes {output}:
0.01 => .01
10.00 => 10
10.10 => 10.1
10.01 => 10.01