This is the script that I am currently using:

<cfscript>
/**
* Rounds any real number to a user specified interval.
* 
* @param nNumber      The number to round. (Required)
* @param nInterval      The number to round to. (Required)
* @param bOption      Used to calculate percentage for rounding. (Optional)
* @return Returns a number. 
* @author Rob Rusher ([email protected]) 
* @version 1, July 20, 2005 
*/
function intervalRound(nNumber, nInterval){
    var nMultipler = fix(nNumber / nInterval); // How many times does the 
interval go into intNumber
    var bOption = 0;

    if(arrayLen(arguments) GTE 3 AND arguments[3])
        if(((nNumber mod nInterval) / nInterval) gte .5) bOption = 1; // 
Calculate percentage for rounding option.

    return (nInterval * nMultipler) + (bOption * nInterval);
}
</cfscript>



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:337126
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to