"f"表示号码后 [英] "f" after number
本文介绍了"f"表示号码后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
数字后的f
表示什么?这是C还是Objective-C的?不将其加到常数上有什么区别吗?
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);
推荐答案
CGRect frame = CGRectMake(0.0f, 0.0f, 320.0f, 50.0f);
使用浮点常量. (常数0.0通常在Objective-C中声明一个双精度;在末尾加一个f-0.0f-将该常数声明为(32位)浮点数.)
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.
这篇关于"f"表示号码后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文