ColdFusion UDF Library - preciseRound
December 16th, 2008
«« Back to ColdFusion Library
Category:
MATH
Description:
Rounds a number to the specified number of places
Parameters:
Returns:
Requires:
Sample Use:
Copy to Clipboard
Category:
MATH
Description:
Rounds a number to the specified number of places
Parameters:
- number (Numeric, required)
The number to perform the rounding operation on. - precision (Numeric, Default: 0)
The number of decimal places to leave in rounding operation. If this number is -1 the number is passed through the function unprocessed. - alt_precision (Numeric, Default: )
If the integer section of the number is zero this alternate decimal precision can be used.
Returns:
Requires:
Sample Use:
Copy to Clipboard
function preciseRound(number){
result = number;
if (ArrayLen(Arguments) gt 1)precision = Arguments[2];
else precision = 0;
if (ArrayLen(Arguments) gt 2 and Int(number) eq 0)precision = Arguments[3];
else precision = Arguments[2];
if (precision gt 0)result = Round(number*(10^precision))/(10^precision);
else result = IIF(precision eq 0,Round(number),number);
return result;
};
// http://www.programmers.org/index.php/coldfusion-udf-library/?ckey=41&function=preciseRound



