"f" after number

floating-point, objective-c

Solution

CGRect frame = CGRectMake(0.0f, 0.0f, 320.0f, 50.0f);

uses float constants. (The constant 0.0 usually declares a double in Objective-C; putting an f on the end - 0.0f - declares the constant as a (32-bit) float.)

CGRect frame = CGRectMake(0, 0, 320, 50);

uses ints which will be automatically converted to floats.

In this case, there's no (practical) difference between the two.

Problem

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? ``` CGRect frame = CGRectMake(0.0f, 0.0f, 320.0f, 50.0f); ``` Can you explain why I wouldn't just write: ``` CGRect frame = CGRectMake(0, 0, 320, 50); ```

Original source

Related problems