DecimalFormat
Converts a number to a decimal-formatted string.
Method Signature
DecimalFormat(number=[any], length=[integer])
Arguments
Argument
Type
Required
Description
Default
number
any
true
The number to convert to decimal format.
length
integer
false
The number of decimal places to include in the formatted string.
2
Examples
Formatting examples
formattedInt = decimalFormat( 123 ); // 123.00
writeOutput( formattedInt & "<br>" );
formattedWithSeparators = decimalFormat( 1000000 ); // 1,000,000.00
writeOutput( formattedWithSeparators & "<br>" );
formattedDecimal = decimalFormat( 987.15 ); // 987.15
writeOutput( formattedDecimal & "<br>" );
formattedRoundedUp = decimalFormat( 456.789 ); // 456.79 - rounds up
writeOutput( formattedRoundedUp & "<br>" );
Additional Examples
writeOutput( decimalFormat( "45" ) & "<br>" ); // 45.00
writeOutput( decimalFormat( 26 ) );
// 26.00;
Related
Last updated
Was this helpful?