Common math functions in C ++

xiaoxiao2021-03-06  57

#include #include using namespace std;

INT main () {Double Pi, E, N; INT I; PI = ACOS (-1.0); E = Exp (1.0); cout << "ABS (-10) =" << ABS (-10) << "/ n"; // seek an absolute value of integer COUT << "FABS (-10.8) =" << FABS (-10.8) << "/ n"; cout << "asin (0.5) =" << asin (0.5) << "(π / 6) / n"; cout << "atan (1.0) =" << Atan (1.0) << "(π / 4) / n"; cout << "atan2 (1.0 , √3) = "<< Atan2 (1.0, SQRT (3.0)) <<" (π / 6) / n "; cout <<" sin (π / 2) = "<< sin (pi / 2.0) < <"/ n"; cout << "sinh (π / 2) =" << SINH (PI / 2.0) << "/ n"; cout << "cos (π / 2) =" << COS (Pi / 2.0) << "(≈0.0) / n"; cout << "Cosh (π / 2) =" << COSH (PI / 2.0) << "/ n"; cout << "tan (π / 4 ) = "<< TAN (PI / 4) <<" / n "; cout <<" tanh (π / 4) = "<< Tanh (pi / 4) <<" / n "; cout <<" CEIL (1.3) = "<< CEIL (1.3) <<" / n "; cout <<" CEIL (-1.3) = "<< CEIL (-1.3) <<" / n "; cout <<" floor (1.3 ) = "<< floor (1.3) <<" / n "; cout <<" floor (-1.3) = "<< floor (-1.3) <<" / n "; cout <<" log (e * e ) = "<< log (e * e) <<" / n "; cout <<" LOG10 (1000.0) = "<< log10 (1000) <<" / n "; COUT << "FMOD (10.2, 3.0) =" << fmod (10.2, 3.0) << "/ n";

COUT << "FMOD (-10.2, 3.0) =" << fmod (-10.2, 3.0) << "/ n"; cout << "POW (25.0, 2.0) =" << Pow (25.0, 2.0) < <"/ n"; cout << "Modf (-12.3435, & n) =" << MODF (-12.3435, & n) << ","; cout << "n = << n <<" / t- 12.3435 = N MODF (-12.3435, & n) / n "; cout <<" frexp (17.0, & i) = "<< frexp (17.0, & i) <<", "; cout <<" i = "<< I << "/T17.0 = frexp (17.0, & i) * 2 ^ I / N"; cout << "LDEXP (0.53125, 5) =" << ldexp (0.53135, 5) << "/tldexp(0.53125 5) = 0.53125 * 2 ^ 5 / n "; return 0;} / * output: ABS (-10) = 10FABS (-10.8) = 10.8asin (0.5) = 0.523599 (π / 6) Atan (1.0) = 0.785398 (π / 4) ATAN2 (1.0, √3) = 0.523599 (π / 6) sin (π / 2) = 1SINH (π / 2) = 2.3013cos (π / 2) = 6.12303E-017 (≈ 0.0) ) Cosh (π / 2) = 2.50918TAN (π / 4) = 1 Tanh (π / 4) = 0.655794ceil (1.3) = 2ceil (-1.3) = -1floor (1.3) = 1floor (-1.3) = -2log E * e) = 2 log10 (1000.0) = 3FMOD (10.2, 3.0) = 1.2FMOD (-10.0) = -1.2Pow (25.0, 2.0) = 625MODF (-12.3435, & n) = -0.3435, n = -12 -12.3435 = N MODF (-12.3435, & n) frexp (17.0, & I) = 0.53125, i = 5 17.0 = frexp (17.0, & i) * 2 ^ Ildexp (0.53125, 5) = 17.0032 LDEX P (0.53125, 5) = 0.53125 * 2 ^ 5 * /

/ * ABS; ASIN; ATAN; Atan2; CEIL; Cos; Cosh; Exp; Fabs; floor; fmod; frexp; ldexp; log; log10; modf; direction; sin; sinh; sqrt; tan;

ACOSF; ATANF; Atan2f; CEILF; COSF; COSHF; Expf; Fabsf; Floorf; FMODF; FREXPF; LDEXPF; LOGF; LOG10F; MODFF; POWF; SINF; SINHF; SQRTF; Tanf; sinf; sinhf; sqrtf; tar; Atan2l; cosl; cosl; coshl; expl; fabsl; floorl; fmodl; frexpl; ldexpl; logl; log10l; modfl; powl; sinl; tanhl; * /

转载请注明原文地址:https://www.9cbs.com/read-109218.html

New Post(0)