码迷,mamicode.com
首页 > 移动开发 > 详细

iOS开发中常用的数学函数

时间:2014-07-05 22:01:45      阅读:390      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   2014   

iOS开发中常用的数学函数

bubuko.com,布布扣

 bubuko.com,布布扣

    /*---- 常用数学公式 ----*/
    
    //指数运算 3^2 3^3
    NSLog(@"结果 %.f", pow(3,2));              //result 9
    NSLog(@"结果 %.f", pow(3,3));              //result 27

    //开平方运算
    NSLog(@"结果 %.f", sqrt(16));              //result 4
    NSLog(@"结果 %.f", sqrt(81));              //result 9
    
    //进一
    NSLog(@"结果 %.f", ceil(3.000000000001));  //result 4
    NSLog(@"结果 %.f", ceil(3.00));            //result 3
    
    //退一
    NSLog(@"结果 %.f", floor(3.000000000001)); //result 3
    NSLog(@"结果 %.f", floor(3.9999999));      //result 3
    
    //四舍五入
    NSLog(@"结果 %.f", round(3.5));            //result 4
    NSLog(@"结果 %.f", round(3.46));           //result 3
    NSLog(@"结果 %.f", round(-3.5));           //NB: this one returns -4
    
    //最小值
    NSLog(@"结果 %.f", fmin(5,10));            //result 5
    
    //最大值
    NSLog(@"结果 %.f", fmax(5,10));            //result 10
    
    //绝对值
    NSLog(@"结果 %.f", fabs(10));              //result 10
    NSLog(@"结果 %.f", fabs(-10));             //result 10

 

iOS开发中常用的数学函数,布布扣,bubuko.com

iOS开发中常用的数学函数

标签:style   blog   http   color   os   2014   

原文地址:http://www.cnblogs.com/YouXianMing/p/3808016.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!