﻿
 详解

# 标准c数学函数

## abs

 ` ``  #include ``  int abs( int num );`

`    int magic_number = 10;`
`    cout << "Enter a guess: ";`
`    cin >> x;`
`    cout << "Your guess was " << abs( magic_number - x ) << " away from the magic number." << endl;`

## acos

 ` ``  #include ``  double acos( double arg );`

asin(), atan(), atan2(), sin(), cos(), tan(), sinh(), cosh(), and tanh().

## asin

 ` ``  #include ``  double asin( double arg );`

acos(), atan(), atan2(), sin(), cos(), tan(), sinh(), cosh(), and tanh().

## atan

 ` ``  #include ``  double atan( double arg );`

asin(), acos(), atan2(), sin(), cos(), tan(), sinh(), cosh(), and tanh().

## atan2

 ` ``  #include ``  double atan2( double y, double x );`

asin(), acos(), atan(), sin(), cos(), tan(), sinh(), cosh(), and tanh().

## ceil

 ` ``  #include ``  double ceil( double num );`

`    y = 6.04;`
`    x = ceil( y );`

x为7.0.

floor() and fmod().

## cos

 ` ``  #include ``  double cos( double arg );`

asin(), acos(), atan(), sin(), atan2(), tan(), sinh(), cosh(), and tanh().

## cosh

 ` ``  #include ``  double cosh( double arg );`

asin(), acos(), atan(), sin(), atan2(), tan(), sinh(), cos(), and tanh().

## div

 ` ``  #include ``  div_t div( int numerator, int denominator );`

`    int quot;     // 商数`
`    int rem;      // 余数`

, 以下代码显示x/y的商和余数:

`    div_t temp;`
`    temp = div( x, y );`
`    printf( "%d divided by %d yields %d with a remainder of %d\n", x, y, temp.quot, temp.rem );`

## exp

 ` ``  #include ``  double exp( double arg );`

## fabs

 ` ``  #include ``  double fabs( double arg );`

## floor

 ` ``  #include ``  double floor( double arg );`

`    y = 6.04;`
`    x = floor( y );`

x的值为6.0.

## fmod

 ` ``  #include ``  double fmod( double x, double y );`

ceil(), floor(), and fabs().

## frexp

 ` ``  #include ``  double frexp( double num, int *exp );`

`    num = mantissa * (2 ^ exp)`

## labs

 ` ``  #include ``  long labs( long num );`

## ldexp

 ` ``  #include ``  double ldexp( double num, int exp );`

frexp() and modf().

## ldiv

 ` ``  #include ``  ldiv_t ldiv( long numerator, long denominator );`

`    long quot;    // 商数 `
`    long rem;     // 余数`

## log

 ` ``  #include ``  double log( double num );`

## log10

 ` ``  #include ``  double log10( double num );`

## modf

 ` ``  #include ``  double modf( double num, double *i );`

frexp() and ldexp().

## pow

 ` ``  #include ``  double pow( double base, double exp );`

exp(), log(), and sqrt().

## sin

 ` ``  #include ``  double sin( double arg );`

asin(), acos(), atan(), cosh(), atan2(), tan(), sinh(), cos(), and tanh().

## sinh

 ` ``  #include ``  double sinh( double arg );`

asin(), acos(), atan(), cosh(), atan2(), tan(), sin(), cos(), and tanh().

## sqrt

 ` ``  #include ``  double sqrt( double num );`

exp(), log(), and pow().

## tan

 ` ``  #include ``  double tan( double arg );`

asin(), acos(), atan(), cosh(), atan2(), sinh(), sin(), cos(), and tanh().

## tanh

 ` ``  #include ``  double tanh( double arg );`

asin(), acos(), atan(), cosh(), atan2(), tan(), sin(), cos(), and sinh().