Mathematical Functions for Real Floating Types
The mathematical
functions declared in
math.h were originally defined only for
double values, with return values and parameters
of type double. These functions are shown in Table 1-30.
|
Mathematical function |
C function |
|
Trigonometric functions:
|
sin(), cos(), tan() asin(), acos() atan(), atan2() |
|
Hyperbolic functions |
sinh(), cosh(), tanh() |
|
Powers, square root |
pow(), sqrt(), |
|
Exponential functions |
exp(), frexp(), ldexp() |
|
Logarithms |
log(), log10() |
|
Next integer |
ceil(), floor() |
|
Absolute value |
fabs() |
|
Remainder (modular division) |
fmod() |
|
Separation of integer and fractional parts |
modf() |
ANSI C99 introduces new versions of
the functions listed in Table 1-30 for the types
float and long double. The
names of these functions end with f or
l; for example:
double cos( double x ); float cosf( float x ); long double cosl( long double x );
New standard mathematical functions for real numbers have also been
added in math.h
, as listed in Table 1-31. These functions also have versions for
float and long double, with
names ending in f and l.
|
Mathematical function |
C function |
|
Trigonometric functions |
asinh(), acosh(), atanh() |
|
Exponential functions |
exp2(), expm1() |
|
Logarithms |
ilogb(), logb(), log1p(), log2() |
|
Roots ... |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access