Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/l/logb.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/l/logb.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/l/logb.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/l/logb.html on line 8

logb(), logbf()

Compute the radix-independent exponent

Synopsis:

#include <math.h>

double logb ( double x );

float logbf ( float x );

Arguments:

x
The number that you want to compute the radix-independent exponent of.

Library:

libm

Use the -l m option to qcc to link against this library.

Description:

The logb() and logbf() functions compute the exponent part of x, which is the integral part of:

logr |x|

as a signed floating point value, for nonzero finite x, where r is the radix of the machine's floating point arithmetic.

Returns:

The binary exponent of x, a signed integer converted to double-precision floating-point.

If x is: logb() returns:
0.0 -HUGE_VAL (errno is set to EDOM)
<0.0 -HUGE_VAL (errno may be set to ERANGE)
±infinity +infinity

Note: If an error occurs, these functions return 0, but this is also a valid mathematical result. If you want to check for errors, set errno to 0, call the function, and then check errno again. These functions don't change errno if no errors occurred.

Examples:

#include <stdio.h>
#include <errno.h>
#include <inttypes.h>
#include <math.h>
#include <fpstatus.h>

int main(int argc, char** argv) 
{
    double a, b;

    a = 0.5;
    b = logb(a);
    printf("logb(%f) = %f (%f = 2^%f) \n", a, b, a, b);

    return(0);
}

produces the output:

logb(0.500000) = -1.000000 (0.500000 = 2^-1.000000)

Classification:

ANSI, POSIX 1003.1

Safety:
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes

See also:

ilogb(), log(), log10(), log1p()


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/l/logb.html on line 193

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/l/logb.html on line 193