Round to the nearest x in ColdFusion

  • Post author:
  • Post category:Uncategorized

On CFTalk today someone wanted to round to the nearest 25000 (it was a real estate app). He got some good suggestions, but I tried them and none of them worked 100% by themselves. So I combined them all and made a function to do this. It takes two parameters, the number you want to round, and the round factor (25000 in the above example). So roundToX(269000,25000) = 275000Update: Barney commented and basically invalidated most of what I was doing, and reduced it all to one line. So I’ve changed the above function to simplify it. 🙂