“f” after number

后端 未结 10 800
醉酒成梦
醉酒成梦 2020-11-27 11:02

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         


        
10条回答
  •  广开言路
    2020-11-27 11:43

    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.

提交回复
热议问题