This must be in documentation somewhere but I cannot find it. What does the .f
mean when defining rectangles using CGSizeMake
as in CGSizeMake(200.0f, 100.0f);
?
Asked
Active
Viewed 1,484 times
-3

rmaddy
- 314,917
- 42
- 532
- 579

user1904273
- 4,562
- 11
- 45
- 96
-
1It has nothing to do with `CGSize`. – rmaddy Jan 02 '16 at 02:11
1 Answers
2
.f means that value is float
.
if you write directly 1.0
it is initialized as double
.
to use less space 1.0f
is better.

meth
- 1,887
- 2
- 18
- 33
-
-
-
3It's not better to use the `.f` here. `CGFloat` may be a `double` or a `float` depending on the device. It's better to just use `1.0` instead of `1.0f`. Then the compiler can adjust the value as needed when compiling. – rmaddy Jan 02 '16 at 02:12
-
1No matter what, the compiler will adjust the value. It's a compile-time constant. Any converting necessary will happen at compile time, too. It would be just as good to use an `int` for an integral value. Any of `1`, `1.0`, and `1.0f` will result in the same binary. – Ken Thomases Jan 02 '16 at 02:19
-