ilogbf, ilogbl, or ilogb Subroutine

Purpose

Returns an unbiased exponent.

Syntax

#include <math.h>

int ilogbf (x)
float x;

int ilogbl (x)
long double x;

int ilogb (x)
double x;

Description

The ilogbf, ilogbl, and ilogb subroutines return the exponent part of the x parameter. The return value is the integral part of logr | x | as a signed integral value, for nonzero x, where r is the radix of the machine's floating-point arithmetic (r=2).

An application wishing to check for error situations should set thre errno global variable 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.

Parameters

Item Description
x Specifies the value to be computed.

Return Values

Upon successful completion, the ilogbf, ilogbl, and ilogb subroutines return the exponent part of x as a signed integer value. They are equivalent to calling the corresponding logb function and casting the returned value to type int.

If x is 0, a domain error occurs, and the value FP_ILOGB0 is returned.

If x is ±Inf, a domain error occurs, and the value {INT_MAX} is returned.

If x is a NaN, a domain error occurs, and the value FP_ILOGBNAN is returned.

If the correct value is greater than {INT_MAX}, {INT_MAX} is returned and a domain error occurs.

If the correct value is less than {INT_MIN}, {INT_MIN} is returned and a domain error occurs.