iOS中的math.h中一些函数

    //2014-01-24 15:39:22.717 test1[771:a0b] 指数运算result:9
    NSLog(@"指数运算result:%.f",pow(3.0, 2.0));
    //2014-01-24 15:41:12.833 test1[788:a0b] 开平方运算:4
    NSLog(@"开平方运算:%.f",sqrt(16));
    //2014-01-24 17:21:20.149 test1[944:a0b] 上舍入取整:4
    //2014-01-24 17:21:20.150 test1[944:a0b] 上舍入取整:3
    NSLog(@"上舍入取整:%.f",ceil(3.1));
    NSLog(@"上舍入取整:%.f",ceil(3.00));
    //2014-01-24 17:21:20.150 test1[944:a0b] 下舍入取整:3
    //2014-01-24 17:21:20.151 test1[944:a0b] 下舍入取整:3
    NSLog(@"下舍入取整:%.f",floor(3.1));
    NSLog(@"下舍入取整:%.f",floor(3.9));
    //2014-01-24 15:58:46.090 test1[853:a0b] 四舍五入:3
    //2014-01-24 15:58:46.091 test1[853:a0b] 四舍五入:4
    NSLog(@"四舍五入:%.f",round(3.4));
    NSLog(@"四舍五入:%.f",round(3.5));
    //2014-01-24 17:17:22.317 test1[905:a0b] 最小值:3
    //2014-01-24 17:17:22.318 test1[905:a0b] 最大值:4
    NSLog(@"最小值:%.f",fmin(3,4));
    NSLog(@"最大值:%.f",fmax(3,4));
    
    //2014-01-24 17:18:15.140 test1[922:a0b] 绝对值:1015
    NSLog(@"绝对值:%.f",fabs(-1015));

三角函数 
正弦 :double sin (double)
余弦 :double cos (double)
正切 :double tan (double)

反三角函数 
反正弦:double asin (double)
反余弦 :double acos (double)
反正切 :double atan (double); 反正切(主值), 结果介于[-PI/2, PI/2] 
double atan2 (double, double); 反正切(整圆值), 结果介于[-PI, PI] 

双曲三角函数 
double sinh (double); 
double cosh (double); 
double tanh (double); 

//指数与对数 
double exp (double);求取自然数e的幂  
double log (double); 以e为底的对数 
double log10 (double);以10为底的对数

//取整 
double ceil (double); 取上整 
double floor (double); 取下整 

//绝对值
double cabs(struct complex znum) ;求复数的绝对值 

//标准化浮点数 
double frexp (double f, int *p); 标准化浮点数, f = x * 2^p, 已知f求x, p ( x介于[0.5, 1] ) 
double ldexp (double x, int p); 与frexp相反, 已知x, p求f 

//取整与取余 
double modf (double, double*); 将参数的整数部分通过指针回传, 返回小数部分 
double fmod (double, double); 返回两参数相除的余数 


double hypot(double x, double y);已知直角三角形两个直角边长度,求斜边长度 
double ldexp(double x, int exponent);计算x*(2的exponent次幂) 
double poly(double x, int degree, double coeffs [] );计算多项式 
int matherr(struct exception *e);数学错误计算处理程序


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值