nearest
nearest
JavaScript Round To The Nearest 5
Sat, 04/11/2009 - 21:50 | by philipnorton42I have already talked about a JavaScript function that rounds To the nearest number, but this was only useful if the number needed to be to the nearest 10 (or factor of). The following function is similar, but will round the number to the nearest 5 or 10, depending which is closer.
JavaScript Round To Nearest Number
Sat, 04/11/2009 - 20:47 | by philipnorton42The JavaScript Math.round() function will round a decimal to the nearest whole number, but I found that I needed was to round a number to the nearest 10. So after a bit of thinking I realised that I could divide the value by 10, round it using the round() function and then multiply the result by 10.
Rounding A Number To Nearest The Thousand In PHP
Sun, 01/06/2008 - 20:12 | by philipnorton42I have previously talked about rounding numbers in PHP, but what if you wanted to round the number to the nearest thousand?