Previous Section 2.6 locale.h |
| Table of Contents | Index | |
Next Section
2.8 setjmp.h |

The math header defines several mathematic functions.

Macros:

```
```**HUGE_VAL**

Functions:

**
acos();**

asin();

atan();

atan2();

ceil();

cos();

cosh();

exp();

fabs();

floor();

fmod();

frexp();

ldexp();

log();

log10();

modf();

pow();

sin();

sinh();

sqrt();

tan();

tanh();

All math.h functions handle errors similarly.

In the case that the argument passed to the function exceeds the range of that function,
then the variable

is set to **errno**

. The value that the function returns is implementation
specific.
**EDOM**

In the case that the value being returned is too large to be represented in a double, then
the function returns the macro

, and sets the variable **HUGE_VAL**

to **errno**

to represent
an overflow. If the value is too small to be represented in a double, then the function returns
zero. In this case whether or not **ERANGE**

is set to **errno**

is implementation specific.
**ERANGE**

, **errno**

, and **EDOM**

are defined in the errno.h header.
**ERANGE**

Note that in all cases when it is stated that there is no range limit, it is implied that the value is limited by the minimum and maximum values of type double.

Declaration:

double acos(doublex

);Returns the arc cosine of

xin radians.

Range:

The valuexmust be within the range of -1 to +1 (inclusive). The returned value is in the range of 0 to pi (inclusive).

Declaration:

Range:

double asin(doublex

);Returns the arc sine of

xin radians.

The value ofxmust be within the range of -1 to +1 (inclusive). The returned value is in the range of -p/2 to +p/2 (inclusive).

Range:

double atan(doublex

);Returns the arc tangent of

xin radians.

The value ofxhas no range. The returned value is in the range of -p/2 to +p/2 (inclusive).

Range:

double atan2(doublyy

, doublex

);Returns the arc tangent in radians of

y/xbased on the signs of both values to determine the correct quadrant.

Bothyandxcannot be zero. The returned value is in the range of -p to +p (inclusive).

Range:

double cos(doublex

);Returns the cosine of a radian angle

x.

The value ofxhas no range. The returned value is in the range of -1 to +1 (inclusive).

Range:

double cosh(doublex

);Returns the hyperbolic cosine of

x.

There is no range limit on the argument or return value.

Range:

double sin(doublex

);Returns the sine of a radian angle

x.

The value ofxhas no range. The returned value is in the range of -1 to +1 (inclusive).

Range:

double sinh(doublex

);Returns the hyperbolic sine of

x.

There is no range limit on the argument or return value.

Range:

double tan(doublex

);Returns the tangent of a radian angle

x.

There is no range limit on the argument or return value.

Range:

double tanh(doublex

);Returns the hyperbolic tangent of

x.

The value ofxhas no range. The returned value is in the range of -1 to +1 (inclusive).

Range:

double exp(doublex

);Returns the value of e raised to the

xth power.

There is no range limit on the argument or return value.

Range:

double frexp(doublex

, int *exponent

);The floating-point number

xis broken up into a mantissa and exponent.

The returned value is the mantissa and the integer pointed to byexponentis the exponent. The resultant value isx=mantissa * 2^exponent.

The mantissa is in the range of .5 (inclusive) to 1 (exclusive).

Range:

double ldexp(doublex

, intexponent

);Returns

xmultiplied by 2 raised to the power ofexponent.

x*2^exponent

There is no range limit on the argument or return value.

Range:

double log(doublex

);Returns the natural logarithm (base-e logarithm) of

x.

There is no range limit on the argument or return value.

Range:

double log10(doublex

);Returns the common logarithm (base-10 logarithm) of

x.

There is no range limit on the argument or return value.

Range:

double modf(doublex

, double *integer

);Breaks the floating-point number

xinto integer and fraction components.

The returned value is the fraction component (part after the decimal), and setsintegerto the integer component.

There is no range limit on the argument or return value.

Range:

double pow(doublex

, doubley

);Returns

xraised to the power ofy.

xcannot be negative ifyis a fractional value.xcannot be zero ifyis less than or equal to zero.

Range:

double sqrt(doublex

);Returns the square root of

x.

The argument cannot be negative. The returned value is always positive.

Range:

double ceil(doublex

);Returns the smallest integer value greater than or equal to

x.

There is no range limit on the argument or return value.

Range:

double fabs(doublex

);Returns the absolute value of

x(a negative value becomes positive, positive value is unchanged).

There is no range limit on the argument. The return value is always positive.

Range:

double floor(doublex

);Returns the largest integer value less than or equal to

x.

There is no range limit on the argument or return value.

Range:

double fmod(doublex

, doubley

);Returns the remainder of

xdivided byy.

There is no range limit on the return value. Ifyis zero, then either a range error will occur or the function will return zero (implementation-defined).

Previous Section 2.6 locale.h |
| Table of Contents | Index | |
Next Section
2.8 setjmp.h |