Math.h
This article is licensed under the GNU Free Documentation License. It uses material from the Wikipedia article "Math.h"
.

content
C Standard Library headers

math.h is a header file in the standard library of C programming language designed for basic mathematical operations. Most of the functions involve the use of floating point numbers. C++ also implements these functions for compatibility reasons and declares them in the header cmath.

All functions that take or return an angle work in radians.

All these functions take doubles for floating-point arguments, unless otherwise specified. To work with floats or long doubles, append an f or an l to the name, respectively.

Contents

Pre-C99 functions

Name Description
acos arccosine
asin arcsine
atan one-parameter arctangent
atan2 two-parameter arctangent
ceil smallest integer not less than parameter
cos cosine
cosh hyperbolic cosine
exp exponential function
fabs absolute value (of a floating-point number)
floor largest integer not greater than parameter
fmod floating-point remainder
frexp break floating-point number down into mantissa and exponent
ldexp scale floating-point number by exponent
log natural logarithm
log10 base-10 logarithm
modf(x,p) returns fractional part of x and stores integral part where pointer p points to
pow(x,y) raise x to the power of y, xy
sin sine
sinh hyperbolic sine
sqrt square root
tan tangent
tanh hyperbolic tangent

C99 functions

Name Description
acosh hyperbolic arccosine
asinh hyperbolic arcsine
atanh hyperbolic arctangent
cbrt cube root
copysign(x,y) returns the value of x with the sign of y
erf error function
erfc complementary error function
exp2(x) raise 2 to the power of x, 2x
expm1(x) one less than the exponential of x, ex − 1
fdim(x,y) positive difference between x and y, fmax(xy, 0)
fma(x,y,z) multiply and add, (x * y) + z
fmax(x,y) largest value of x and y
fmin(x,y) smallest value of x and y
hypot(x,y) hypotenuse, sqrt(x2 + y2)
ilogb the exponent of a floating-point value, converted to an int
lgamma natural log of the absolute value of the gamma function
llrint round to integer (returns long long) using current rounding mode
lrint round to integer (returns long) using current rounding mode
llround round to integer (returns long long)
lround round to integer (returns long)
log1p(x) natural logarithm of 1 + x
log2 base-2 logarithm
logb extract exponent from floating-point number
nan(s) returns NaN, possibly using string argument
nearbyint round floating-point number to nearest integer
nextafter(x,y) returns next representable value after x (towards y)
nexttoward(x,y) same as nextafter, except y is always a long double
remainder(x,y) calculates remainder, as required by IEC 60559
remquo(x,y,p) same as remainder, but store quotient (as int) at target of pointer p
rint round to integer (returns int) using current rounding mode
round round to integer (returns int)
scalbln(x,n) x * FLT_RADIXn (n is long)
scalbn(x,n) x * FLT_RADIXn (n is int)
tgamma gamma function
trunc truncate floating-point number

XSI Extensions

Extra functions may be available as X/Open System Interfaces Extensions. These are not present in any ANSI or ISO C standard.

Name Description
j0(x) Bessel function of x of the first kind of order 0
j1(x) Bessel function of x of the first kind of order 1
jn(n,x) Bessel function of x of the first kind of order n
scalb(x,y) x * FLT_RADIXy (x and y are doubles)
y0(x) Bessel function of x of the second kind of order 0
y1(x) Bessel function of x of the second kind of order 1
yn(n,x) Bessel function of x of the second kind of order n

The double-to-string conversion functions ecvt, fcvt and gcvt have been deprecated in favour of sprintf.

Extra links

© jGames.co.uk 2007 (some content from Wikipedia under GDL ) !-- ValueClick Media 468x60 and 728x90 Banner CODE for jgames.co.uk -->
Your Ad Here