iOS 四舍五入 进位 取整的计算函数

#pragma mark === 四舍五入

-(int)roundedRoundfWith:(float)numberToRound

{

    int result;

   result = (int)roundf(numberToRound);

    NSLog(@"roundf(%.2f) = %d", numberToRound, result);

    //

    return result;

}

#pragma mark === 进位

-(int)roundedCeilfWith:(float)numberToRound

{

    int result;


    result = (int)ceilf(numberToRound);


    NSLog(@"roundf(%.2f) = %d", numberToRound, result);


    return result;

}

#pragma mark === 摸位 取整

-(int)floatChangeToIntWith:(float)numberToRound

{

    int result;


   result = (int)floorf(numberToRound);


    NSLog(@"roundf(%.2f) = %d", numberToRound, result);


    return result;

}

你可能感兴趣的:(iOS 四舍五入 进位 取整的计算函数)