Constant
Constant name |
Description |
M_pi |
Circumference rate (= π) |
M_pi_2 |
1/2 of the circumference rate (= π/2) |
M_pi_4 |
1/4 of the circumference rate (= π/4) |
M_1_pi |
= 1/π |
M_2_pi |
= 2/π |
M_e |
= E |
M_log2e |
Log_2 (E) |
M_log10e |
Log_10 (E) |
Arithmetic functions
function name |
description |
int rand () |
random number generation. (example) srand (Time (NiL); // initial random number int val = rand () % 50; // 0 ~ Random Number between 49 |
int ABS (int A) |
absolute value of an integer (example) int val = ABS (-8); → 8 ※fabs is used for Floating Point. |
double FABS (double A) |
absolute value of a floating point (for example, double val = FABS (-12.345); → 12.345 ※abs is used for integers. |
double floor (double A) |
return the integer part of the floating point number (discard the decimal point) (example) Double val = floor (12.345); → 12.000 |
double Ceil (double A); |
return the integer part of the floating point number (discard the decimal part and Add 1 to the single digit) (example) Double val = Ceil (12.345); → 13.000 |
double POW (double A, double B) |
B power of a (example) Double val = POW (2, 3); → 8 |
double SQRT (double A) |
square root of a (example) Double val = SQRT (2); → 1.41421356 |
Expression of arithmetic functions and constants in objective-C