Rounding numbers to a specific resolution
问题 I know many languages have the ability to round to a certain number of decimal places, such as with the Python: >>> print round (123.123, 1) 123.1 >>> print round (123.123, -1) 120.0 But how do we round to an arbitrary resolution that is not a decimal multiple. For example, if I wanted to round a number to the nearest half or third so that: 123.123 rounded to nearest half is 123.0. 456.456 rounded to nearest half is 456.5. 789.789 rounded to nearest half is 790.0. 123.123 rounded to nearest