When setting whole CGFloat values (and thus by implication float and double values) is it best practice to include the decimal point or does it not matter? For example:
CGRect rect1 = CGRectMake(0, 10, 100, 200); // Approach 1
CGRect rect2 = CGRectMake(0.0, 10.0, 100.0, 200.0); // Approach 2
The compiler will do an implicit conversion to float, so either method should result in the same float value.
However, your Approach 2 is actually specifying a value of type double, which is then converted to float. To explicitly specify a float you need to add an
fsuffix ie200.0fPersonally I always specify values like this as
xxx.0fjust to keep reminding me that they are floats, and screw the extra work the compiler has to do to interpret my code – it’s there to do my bidding, not the other way around.Of course I would also do: