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 to round down, similar to the Gauss function [] in mathematics. It obtains the maximum integer not greater than the floating point number. For positive numbers, it discards the floating point number part. For complex numbers, it discards the floating point number part and then subtracts 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); Calculates the y power with x as the base

Float powf (float x, float y); the function is the same as that of pow, except that both input and output are 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, x can be obtained, p (x is between [0.5, 1])

Double ldxp (double x, int p); in contrast to frexp, if x and p are known, calculate f

8. Rounding and Remaining

Double modf (double, double *); returns the integer part of the parameter through the pointer and returns the decimal part

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 ldxp (double x, int exponential); 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