Round a number
To round a number use the following code:
CGFloat variable = ...CGFloat result = round(variable * 1000.0) / 1000.0;
or
CGFloat variable = round(variable * 1000.0) / 1000.0;[/code]
Use 1000 for 3decimal places, 100 for 2 etc!
Category: Programming

Comments