Round a float, and force a specific number of decimal places

Check this post for a Matlab-like solution.