Rounding To The Nearest Integer Specified
While working with currency calculations, we often require to round a number to the nearest 10 or the nearest 50, like 407 should be 410.
I've written a function which will do exactly that, it requires two parameters the number to the round, and the integer to be rounded to. The function is like MROUND found in MS Excel & OpenOffice Spreadsheet. Code: PHP
Code: PHP
Code:
30 
Re: Rounding To The Nearest Integer Specified
Rounding involves reducing the number of significant digits in a number. The result of rounding is a "shorter" number having fewer nonzero digits yet similar in magnitude. The result is less precise but easier to use.
For example: 73 rounded to the nearest ten is 70, because 73 is closer to 70 than to 80. Researchers may analyze rounding as a form of quantization. 
Re: Rounding To The Nearest Integer Specified
Function requires 3rd parameter: precision. Just to describe which part of number would be rounded(befoer dot or after). Also it will be fine if 4th parameter will allow to round prices to 99 cents. Like for input 16 it will return 15.99.:):):)

All times are GMT +5.5. The time now is 11:31. 