iphone中的舍入值

iphone中的舍入值,iphone,objective-c,ios,ios4,Iphone,Objective C,Ios,Ios4,我正在创建描述标签,其中我希望我的描述标签高度应取决于从表达式取整的值 NSString *description = [dic objectForKey:@"des"]; UIFont *font = [UIFont boldSystemFontOfSize:8]; CGSize desSize = [description sizeWithFont:font]; float hgt = desSize.width / userView.frame.size.w

我正在创建描述标签,其中我希望我的描述标签高度应取决于从表达式取整的值

    NSString *description = [dic objectForKey:@"des"];
    UIFont *font = [UIFont boldSystemFontOfSize:8];
    CGSize desSize = [description sizeWithFont:font];
    float hgt = desSize.width / userView.frame.size.width;
我想,hgt的值应该是精确的数字,比如说,如果输出值是0.1,那么它应该给我,hgt的值是1,另一个像,如果除法的o/p值是3.3,那么hgt应该变成4

请帮我解决这个问题

用以汇总

float hgt = ceil(desSize.width / userView.frame.size.width);
你想用ceil。这将把数字四舍五入到最接近的整数

fabs() – Find the absolute value or unsigned value in parentheses.
result = fabs(x); // fabs(-2.5) = 2.5

ceil() – To round up
i = ceil(x); // ceil(3.5) = 4

floor() – find the integer that is below the floating point value.
i = floor(x); // floor(4.2) = 4

pow() – raise a number to the power.
i = pow(x,y); //pow(4,2) = 16

sqrt() – Square root of a number.
i = sqrt(x); // sqrt(16) = 4

exp() – find the expoential value.