本文介绍了“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"编号后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 05:24