-3

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);?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
user1904273
  • 4,562
  • 11
  • 45
  • 96

1 Answers1

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
  • what else could it be? – user1904273 Jan 02 '16 at 01:43
  • ok. Thx. will mark correct when it lets me! – user1904273 Jan 02 '16 at 01:44
  • 3
    It'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
  • 1
    No 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
  • You are both right. thanks for clarification. – meth Jan 02 '16 at 12:13