zoukankan      html  css  js  c++  java
  • OC常用函数及变量

    1、OC常用的的函数及变量

    (1)算术函数

    【算术函数】
    函数名说明
    int rand() 随机数生成。
    (例)
    srand(time(nil)); //随机数初期化
    int val = rand()P; //0~49之间的随机数
    int abs(int a) 整数的绝对值
    (例)int val = abs(-8);
     →8
    ※浮点数的时候用fabs。
    double fabs(double a) 浮点数的绝对值
    (例)double val = fabs(-12.345);
     →12.345
    ※整数的时候用abs。
    double floor(double a) 返回浮点数整数部分(舍弃小数点)
    (例)double val = floor(12.345);
     →12.000
    double ceil(double a); 返回浮点数整数部分(舍弃小数点部分,往个位数进1)
    (例)double val = ceil(12.345);
     →13.000
    double pow(double a, double b) a的b次方
    (例)double val = pow(2, 3);
     →8
    double sqrt(double a) a的平方根
    (例)double val = sqrt(2);
     →1.41421356

    (2)三角函数

    【三角函数】
    函数名说明
    double cos(double a) 余弦函数 (a:弧度)
    double sin(double a) 正弦函数 (a:弧度)
    double tan(double a) 正切函数 (a:弧度)
    double asin(double a) 反正弦值 (a:弧度)
    double acos(double a) 反余弦函数(a:弧度)
    double atan(double a) 反正切函数
    double atan2(double a, double b) 返回给定的 a 及 b 坐标值的反正切值

    (3)指数函数

    【指数函数】
    函数名说明
    double log(double a) 以e 为底的对数值
    double log10(double a) 对数函数log

    (4)常数

     

    常数
    常数名说明
    M_PI 圆周率(=π)
    M_PI_2 圆周率的1/2(=π/2)
    M_PI_4 圆周率的1/4(=π/4)
    M_1_PI =1/π
    M_2_PI =2/π
    M_E =e
    M_LOG2E log_2(e)
    M_LOG10E log_10(e)

    转自: http://blog.csdn.net/chenyong05314/article/details/18963137

  • 相关阅读:
    poj 1113 Wall 凸包的应用
    NYOJ 78 圈水池 (入门级凸包)
    Monotone Chain Convex Hull(单调链凸包)
    poj Sudoku(数独) DFS
    poj 3009 Curling 2.0(dfs)
    poj 3083 Children of the Candy Corn
    Python join()方法
    通过FISH和下一代测序检测肺腺癌ALK基因融合比较
    华大病原微生物检测
    NGS检测ALK融合大起底--转载
  • 原文地址:https://www.cnblogs.com/yang-shuai/p/7150796.html
Copyright © 2011-2022 走看看