iOS开发之----常用函数和常数
介绍一下Objective-c常用的函数,常数变量
算术函数
| 函数名 | 说明 |
|---|---|
| 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 |
三角函数
| 函数名 | 说明 |
|---|---|
| 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 坐标值的反正切值 |
指数函数
| 函数名 | 说明 |
|---|---|
| double log(double a) | 以e 为底的对数值 |
| double log10(double a) | 对数函数log |
常数
| 常数名 | 说明 |
|---|---|
| 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) |
原文链接:IOS开发之----常用函数和常数
iOS开发之----常用函数和常数的更多相关文章
- IOS开发之----常用函数和常数--秀清
介绍一下Objective-c常用的函数,常数变量 算术函数 [算术函数] 函数名 说明 int rand() 随机数生成.(例)srand(time(nil)); //随机数初期化int val = ...
- iOS开发中常用的数学函数
iOS开发中常用的数学函数 /*---- 常用数学公式 ----*/ //指数运算 3^2 3^3 NSLog(,)); //result 9 NSLog(,)); //result 27 //开平方 ...
- iOS开发之常用第三方框架(下载地址,使用方法,总结)
iOS开发之常用第三方框架(下载地址,使用方法,总结) 说句实话,自学了这么久iOS,如果说我不知道的但是又基本上都摸遍了iOS相关知识,但是每次做项目的时候,遇到难一点的地方或者没试过的东西就闷了. ...
- iOS开发API常用英语名词
iOS开发API常用英语名词 0. indicating 决定 1.in order to 以便 2.rectangle bounds 矩形尺寸 3.applied 应用 4.entirety 全部 ...
- iOS导航控制器常用函数与navigationBar常用属性
导航控制器常用函数触发时机 当视图控制器的View将要出现时触发 - (void)viewWillAppear:(BOOL)animated 当视图控制器的View已经出现时触发 - (void)vi ...
- IOS开发之----常用的基本GDB命令【转】
原文地址:http://blog.sina.com.cn/s/blog_71715bf801016d2y.html gdb不是万能的,可是没有gdb却是万万不能的.这里给大家简单介绍下iOS开发中最基 ...
- iOS开发——C篇&函数解析
关于函数,作为一个开发者事必须掌握的知识不管你在那一个领域,所以今天我就来说一说函数. 一:函数的介绍 关于函数,其实笔者在前面都已经演示不少了,其中用的最多的就是main函数,虽然直接说函数可能不太 ...
- iOS 开发设计常用软件及工具整理
1, xCode 2, AppCode 3, Skech 原型设计软件 4, Hype 动画设计工具 5, fontawsome 免费图表 6, Prepo icon, images.catlog 生 ...
- iOS开发中 常用枚举和常用的一些运算符(易错总结)
1.色值的随机值: #define kColorValue arc4random_uniform(256)/255.0 // arc4random_uniform(256)/255.0; 求出0.0~ ...
随机推荐
- SharePoint 2010 ——自定义上传页面与多文件上传解决方案
最近项目遇到一个很麻烦的问题,原以为很容易解决,结果搞了那么久,先开个头,再慢慢写 SharePoint 2010 ——自定义上传页面与多文件上传解决方案 1.创建Sharepoint空白项目,创建应 ...
- UC如被百度控股,手机qq浏览器改如何进攻和防守
很早以前在公司内部论坛里写的一篇文章,绯闻已经过过去了,现在已物事人物,UC已有阿里大靠山了. ----------------------------------------------- 据网络媒 ...
- UnityShader之Shader分类篇【Shader资料2】
关于ShaderLab,从我个人的理解上来看应该是分为三种类型. 1.Fixed function shader 固定渲染管线Shader,基于用于高级Shader在老显卡无法显示时的Fallback ...
- iOS之微博UI实例--拟物化设计(成功了90%)
*:first-child { margin-top: 0 !important; } body > *:last-child { margin-bottom: 0 !important; } ...
- OC小实例关于init方法不小心的错误
*:first-child { margin-top: 0 !important; } body > *:last-child { margin-bottom: 0 !important; } ...
- 集成ZBar时容易遇到的问题以及解决方法
1.添加入几个必备的框架: libiconv.tbd QuartzCore.framework CoreVideo.framework CoreMedia.framework AVFoundation ...
- Android中有时候运行程序的时候会报错:An internal error occurred during:。。。。
解决办法: Project -> Properties -> Run/Debug Settings: 1. select "Launching New_configuration ...
- 分享git的常用命令
Git操作笔记 1.创建目录 $ mkdir learngit $ cd learngit 2.把新建的目录变成仓库 $ git ...
- yum安装mariadb
安装mysql yum install mariadb mariadb-server MySQL-python mysql-devel Package MySQL-python-1.2.5-1.ibm ...
- Web Application Project is configured to use IIS. Unable to access the IIS metabase.(配置为使用IIS Web应用程序xxxx项目。无法访问IIS元数据库。)
这几天重装系统,装了win10,居然用vs2013打开项目出现下面这个提示错误,搞了很久才知道原因: Even though I am an administrator on the machine, ...