Math functions in Object-C

2015-03-31  本文已影响13人  Nirvana_icy
  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
上一篇下一篇

猜你喜欢

热点阅读