What does the f
after the numbers indicate? Is this from C or Objective-C? Is there any difference in not adding this to a constant number?
CGRec
From C. It means float literal constant. You can omit both "f" and ".0" and use ints in your example because of implicit conversion of ints to floats.
Sometimes there is a difference.
float f = 0.3; /* OK, throw away bits to convert 0.3 from double to float */
assert ( f == 0.3 ); /* not OK, f is converted from float to double
and the value of 0.3 depends on how many bits you use to represent it. */
assert ( f == 0.3f ); /* OK, comparing two floats, although == is finicky. */
It is almost certainly from C and reflects the desire to use a 'float' rather than a 'double' type. It is similar to suffixes such as L on numbers to indicate they are long integers. You can just use integers and the compiler will auto convert as appropriate (for this specific scenario).
The f
that you are talking about is probably meant to tell the compiler that it's working with a float. When you omit the f
, it is usually translated to a double.
Both are floating point numbers, but a float
uses less bits (thus smaller and less precise) than a double
.