logbf, logbl, or logb Subroutine

Purpose

Computes the radix-independent exponent.

Syntax

#include <math.h>

float logbf (x)
float x;

long double logbl (x)
long double x;

double logb(x)
double x;

Description

The logbf and logbl subroutines compute the exponent of x, which is the integral part of logr | x |, as a signed floating-point value, for nonzero x, where r is the radix of the machine's floating-point arithmetic. For AIX®, FLT_RADIX r=2.

If x is subnormal, it is treated as though it were normalized; thus for finite positive x:

1 <= x * FLT_RADIX-logb(x) < FLT_RADIX

An application wishing to check for error situations should set errno to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these subroutines. Upon return, if errno is nonzero or fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is nonzero, an error has occurred.

Note: When the x parameter is finite and not zero, the logb (x) subroutine satisfies the following equation:
1 < = scalb (|x|, -(int) logb (x)) < 2

Parameters

Item Description
x Specifies the value to be computed.

Return Values

Upon successful completion, the logbf and logbl subroutines return the exponent of x.

If x is ±0, a pole error occurs and the logbf and logbl subroutines return -HUGE_VALF and -HUGE_VALL, respectively.

If x is NaN, a NaN is returned.

If x is ±Inf, +Inf is returned.

Error Codes

The logb function returns -HUGE_VAL when the x parameter is set to a value of 0 and sets errno to EDOM.