Math functions in Object-C
- double pow ( double, double ) - power of
NSLog(@"%.f", pow(3,2) ); //result 9
- double sqrt( double ) - square root
NSLog(@"%.f", sqrt(16) ); //result 4
- 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
- double floor ( double ) - removes the decimal part of the argument
NSLog(@"res: %.f", floor(3.9999999));
- 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
网友评论