Quick check of iOS function

  • content
  • comment
  • relevant

1. Gauss function, rounded down

floor(1.0/4)=0;

floor(4.0/4)=1;

floor(5.0/4)=1;

floor(8.0/4)=2;

The floor () method is rounded down, similar to the Gaussian function [] in mathematics Get the largest integer not greater than the floating point number. For positive numbers, discard the floating point number part. For complex numbers, discard the floating point number part and then subtract 1

2. ceil function, rounded up.

For example:

ceil(1.0/4)=1;

ceil(4.0/4)=1;

ceil(5.0/4)=2;

ceil(8.0/4)=2;

The ceil() method is to round up, Double type in parentheses

These two functions are in the math. h library. You can use them directly. IOS does not need to pour the header file again. There are many mathematical functions like this, such as

1. Trigonometric function

double sin (double); Sine

double cos (double); cosine

double tan (double); tangent

2. Inverse trigonometric function

double asin (double); Results between [- PI/2, PI/2]

double acos (double); The result is between [0, PI]

double atan (double); Arctangent (major value), the result is between [- PI/2, PI/2]

double atan2 (double, double); Arctangent (full circle value), the result is between [- PI, PI]

3. Hyperbolic trigonometric function

double sinh (double);

double cosh (double);

double tanh (double);

4. Exponential and logarithmic

double exp (double); Finding the power of natural number e

double sqrt (double); Square root

double log (double); Logarithm with e as the base

double log10 (double); Base 10 logarithm

double pow(double x, double y); Calculate the y power with x as the base

float powf(float x, float y); The function is the same as that of pow, but the input and output are both floating point numbers

5. Rounding

double ceil (double); Rounded up

double floor (double); Remove the integer

6. Absolute value

double fabs (double); Find absolute value

double cabs(struct complex znum) ; Find the absolute value of complex number

7. Standardized floating point number

double frexp (double f, int *p); Standardized floating point number, f=x * 2 ^ p, if f is known, calculate x, p (x is between [0.5, 1])

double ldexp (double x, int p); Contrary to frexp, if x and p are known, calculate f

8. Rounding and Remaining

double modf (double, double*); The integer part of the parameter is returned through the pointer, and the decimal part is returned

double fmod (double, double); Returns the remainder of the division of two parameters

9. Others

double hypot(double x, double y); Given the length of two right sides of a right triangle, calculate the length of the hypotenuse

double ldexp(double x, int exponent); Calculate x * (the exponential power of 2)

double poly(double x, int degree, double coeffs [] ); Compute Polynomial

int matherr(struct exception *e); Mathematical error calculation processing program

comment

zero Comments

Post reply

Your email address will not be disclosed. Required items have been used * tagging