Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
These functions compute
e(the base of natural logarithms) raised to the power x.If the magnitude of the result is too large to be representable,
expsignals overflow.
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
These functions compute
2raised to the power x. Mathematically,exp2 (x)is the same asexp (x * log (2)).
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
These functions compute
10raised to the power x. Mathematically,exp10 (x)is the same asexp (x * log (10)).The
exp10functions are from TS 18661-4:2015.
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
These functions compute the natural logarithm of x.
exp (log (x))equals x, exactly in mathematics and approximately in C.If x is negative,
logsignals a domain error. If x is zero, it returns negative infinity; if x is too close to zero, it may signal overflow.
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
These functions return the base-10 logarithm of x.
log10 (x)equalslog (x) / log (10).
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
These functions return the base-2 logarithm of x.
log2 (x)equalslog (x) / log (2).
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
These functions extract the exponent of x and return it as a floating-point value. If
FLT_RADIXis two,logbis equal tofloor (log2 (x)), except it's probably faster.If x is de-normalized,
logbreturns the exponent x would have if it were normalized. If x is infinity (positive or negative),logbreturns ∞. If x is zero,logbreturns ∞. It does not signal.
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
These functions are equivalent to the corresponding
logbfunctions except that they return signed integer values. Theilogb,ilogbf, andilogblfunctions are from ISO C99; thellogb,llogbf,llogblfunctions are from TS 18661-1:2014; theilogbfN,ilogbfNx,llogbfN, andllogbfNxfunctions are from TS 18661-3:2015.
Since integers cannot represent infinity and NaN, ilogb instead
returns an integer that can't be the exponent of a normal floating-point
number. math.h defines constants so you can check for this.
ilogbreturns this value if its argument is0. The numeric value is eitherINT_MINor-INT_MAX.This macro is defined in ISO C99.
llogbreturns this value if its argument is0. The numeric value is eitherLONG_MINor-LONG_MAX.This macro is defined in TS 18661-1:2014.
ilogbreturns this value if its argument isNaN. The numeric value is eitherINT_MINorINT_MAX.This macro is defined in ISO C99.
llogbreturns this value if its argument isNaN. The numeric value is eitherLONG_MINorLONG_MAX.This macro is defined in TS 18661-1:2014.
These values are system specific. They might even be the same. The
proper way to test the result of ilogb is as follows:
i = ilogb (f);
if (i == FP_ILOGB0 || i == FP_ILOGBNAN)
{
if (isnan (f))
{
/* Handle NaN. */
}
else if (f == 0.0)
{
/* Handle 0.0. */
}
else
{
/* Some other value with large exponent,
perhaps +Inf. */
}
}
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
These are general exponentiation functions, returning base raised to power.
Mathematically,
powwould return a complex number when base is negative and power is not an integral value.powcan't do that, so instead it signals a domain error.powmay also underflow or overflow the destination type.
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
These functions return the nonnegative square root of x.
If x is negative,
sqrtsignals a domain error. Mathematically, it should return a complex number.
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
These functions return the cube root of x. They cannot fail; every representable real value has a representable real cube root.
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
These functions return
sqrt (x*x+y*y). This is the length of the hypotenuse of a right triangle with sides of length x and y, or the distance of the point (x, y) from the origin. Using this function instead of the direct formula is wise, since the error is much smaller. See also the functioncabsin Absolute Value.
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
These functions return a value equivalent to
exp (x) - 1. They are computed in a way that is accurate even if x is near zero—a case whereexp (x) - 1would be inaccurate owing to subtraction of two numbers that are nearly equal.
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
These functions return a value equivalent to
log (1 +x). They are computed in a way that is accurate even if x is near zero.
ISO C99 defines complex variants of some of the exponentiation and logarithm functions.
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
These functions return
e(the base of natural logarithms) raised to the power of z. Mathematically, this corresponds to the valueexp (z) = exp (creal (z)) * (cos (cimag (z)) + I * sin (cimag (z)))
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
These functions return the natural logarithm of z. Mathematically, this corresponds to the value
log (z) = log (cabs (z)) + I * carg (z)
cloghas a pole at 0, and will signal overflow if z equals or is very close to 0. It is well-defined for all other values of z.
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
These functions return the base 10 logarithm of the complex value z. Mathematically, this corresponds to the value
log10 (z) = log10 (cabs (z)) + I * carg (z) / log (10)
All these functions, including the
_FloatN and_FloatNxvariants, are GNU extensions.
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
These functions return the complex square root of the argument z. Unlike the real-valued functions, they are defined for all values of z.
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
These functions return base raised to the power of power. This is equivalent to
cexp (y * clog (x))