logb, logbf, logbl
Defined in header <math.h>
|
||
float logbf( float arg ); |
(1) | (since C99) |
double logb( double arg ); |
(2) | (since C99) |
long double logbl( long double arg ); |
(3) | (since C99) |
Defined in header <tgmath.h>
|
||
#define logb( arg ) |
(4) | (since C99) |
arg
, and returns it as a floating-point value. arg
has type long double, logbl
is called. Otherwise, if arg
has integer type or the type double, logb
is called. Otherwise, logbf
is called.Formally, the unbiased exponent is the signed integral part of log
r|arg| (returned by this function as a floating-point value), for non-zero arg, where r
is FLT_RADIX. If arg
is subnormal, it is treated as though it was normalized.
Parameters
arg | - | floating point value |
Return value
If no errors occur, the unbiased exponent of arg
is returned as a signed floating-point value.
If a domain error occurs, an implementation-defined value is returned
If a pole error occurs, -HUGE_VAL
, -HUGE_VALF
, or -HUGE_VALL
is returned.
Error handling
Errors are reported as specified in math_errhandling.
Domain or range error may occur if arg
is zero.
If the implementation supports IEEE floating-point arithmetic (IEC 60559),
- If
arg
is ±0, -∞ is returned and FE_DIVBYZERO is raised. - If
arg
is ±∞, +∞ is returned - If
arg
is NaN, NaN is returned. - In all other cases, the result is exact (FE_INEXACT is never raised) and the current rounding mode is ignored
Notes
POSIX requires that a pole error occurs if arg
is ±0.
The value of the exponent returned by logb
is always 1 less than the exponent retuned by frexp because of the different normalization requirements: for the exponent e
returned by logb
, |arg*r-e
| is between 1 and r
(typically between 1 and 2), but for the exponent e
returned by frexp, |arg*2-e
| is between 0.5 and 1.