Introduce the functions commonly used in objective-c, constant variables

Source: Internet
Author: User

Transferred from: http://blog.sina.com.cn/s/blog_71715bf80101bnvn.html

Arithmetic functions
"Arithmetic function"
Name of function Description
int rand () Random number generation.
Cases
Srand (Time (nil)); Initial random number initialization
int val = rand () P; Random number between 0~49
int abs (int a) Absolute value of an integer
(example) int val = ABS (-8);
→8
* Use fabs when floating-point numbers.
Double Fabs (Double A) Absolute value of floating-point numbers
(example) Double val = fabs (-12.345);
→12.345
※the whole number is used abs.
Double floor (Double a) Returns the integer portion of a floating-point number (discarding a decimal point)
(example) Double val = floor (12.345);
→12.000
Double Ceil (double A); Returns the integer portion of a floating-point number (discards the decimal point and enters 1 digits)
(example) Double val = ceil (12.345);
→13.000
Double Pow (double A, double b) A's B-square
(example) Double val = Pow (2, 3);
→8
Double sqrt (double A) Square root of a
(example) Double val = sqrt (2);
→1.41421356
Trigonometric function
Trigonometric functions
Name of function Description
Double cos (double a) Cosine function (A: radians)
Double sin (double A) Sine function (A: radians)
Double tan (Double A) Tangent function (A: radians)
Double asin (Double A) Inverse chord value (a: radians)
Double ACOs (Double A) Inverse cosine function (A: radians)
Double Atan (Double A) Inverse tangent function
Double atan2 (double A, double b) Returns the inverse tangent value of the given a and B coordinate values
exponential function
"Exponential function"
Name of function Description
Double log (double A) The value of the pairs based on the base E
Double log10 (Double A) Log function Log
Constant
Constant
Constant Number name Description
M_pi Pi (=π)
M_pi_2 1/2 of Pi (=Π/2)
M_pi_4 1/4 of Pi (=Π/4)
M_1_pi =1/π
M_2_pi =2/π
M_e =e
m_log2e Log_2 (e)
m_log10e Log_10 (e)

Introduce the functions commonly used in objective-c, constant variables

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.