美文网首页
Math functions in Object-C

Math functions in Object-C

作者: Nirvana_icy | 来源:发表于2015-03-31 14:28 被阅读13次
    1. double pow ( double, double ) - power of
      NSLog(@"%.f", pow(3,2) ); //result 9
    2. double sqrt( double ) - square root
      NSLog(@"%.f", sqrt(16) ); //result 4
    3. double ceil ( double ) - if the argument has any decimal part, returns the next bigger integer
      NSLog(@"res: %.f", ceil(3.000000000001)); //result 4
      NSLog(@"res: %.f", ceil(3.00)); //result 3
    4. double floor ( double ) - removes the decimal part of the argument
      NSLog(@"res: %.f", floor(3.9999999));
    5. double round ( double ) - rounds the argument
      NSLog(@"res: %.f", round(3.46)); //result 3

    相关文章

      网友评论

          本文标题:Math functions in Object-C

          本文链接:https://www.haomeiwen.com/subject/rtloxttx.html