本文介绍了"餐饮QUOT;经过数/浮在Objective-C / C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不能在苹果的文档,以便找到这个:数字后什么是F表示在这里?这是从C或Objective-C?有没有不加入这一个常数什么区别呢?

 的CGRect帧= CGRectMake(0.0,0.0,320.0f,50.0f);

你能解释我为什么会不只是写:

 的CGRect帧= CGRectMake(0,0,320,50);


解决方案

 的CGRect帧= CGRectMake(0.0,0.0,320.0f,50.0f);

使用浮动常量。 (恒定0.0通常声明在Objective-C双;将一个F上月底 - 0.0 - 声明常数作为(32位)浮点数)

 的CGRect帧= CGRectMake(0,0,320,50);

使用,将被自动转换为花车整数。

在这种情况下,有两者之间没有(实际)的区别。

I cannot find this in the Apple docs so: what does the "f" after the numbers here 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);

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.

这篇关于"餐饮QUOT;经过数/浮在Objective-C / C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 08:40