round
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.
Round A Number In MS SQL
Mon, 11/10/2008 - 10:20 | by philipnorton42To round a number in MS SQL use the ROUND() function. This function takes two parameters, the first is the number to be rounded and the second is the number of decimal places to round the number to. Here is an example of rounding the numbers in a column to the nearest whole integer.
SELECT ROUND(table.column1,0) rentValue FROM table
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?
Rounding And Displaying Numbers In PHP
Mon, 12/24/2007 - 11:01 | by philipnorton42To round a number in PHP you can use one of three functions, these are round(), ceil() and floor(). All of these functions take number as the input and will round the value depending on the function used.
To round to the closest integer use the round() function.
round(4.4); // returns 4
To round down to the nearest whole number use the floor() function.