Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ frexp(3C) — Reliant UNIX 5.44c4

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

cc(1)

math(5)

frexp(3C)                                                         frexp(3C)

NAME
     frexp, ldexp, logb, ilogb, nextafter, scalb, modf, modff - manipulate
     parts of floating-point numbers

SYNOPSIS
     #include <math.h>

     double frexp(double num, int *exp);

     double ldexp(double x, int exp);

     double logb(double x);

     int ilogb(double x);

     double nextafter(double x, double y);

     double scalb(double x, double n);

     double modf(double x, double *iptr);

     float modff(float value, float *iptr);

DESCRIPTION
     frexp() breaks a floating-point number into a normalized fraction and
     an integral power of 2. It stores the integer exponent in the int
     object pointed to by exp.

     ldexp() returns the quantity x * 2^exp.

     scalb() computes x * r^n, where r is the radix of the machine's float-
     ing point arithmetic. When r is 2, scalb() is equivalent to ldexp().

     logb() computes the exponent of x, which is the integral part of
     logr|x|, as a signed floating point value, for non-zero x, where r is
     the radix of the machine's floating-point arithmetic.

     ilogb() returns the exponent part of x. Formally, the return value is
     the integral part of logr|x| as a signed integral value, for non-zero
     x, where r is the radix of the machine's floating point arithmetic.

     The call ilogb(x) is equivalent to (int)logb(x).

     modf() and modff() (single-precision version) return the fractional
     part of x and store the integral part indirectly in the location
     pointed to by iptr. Both parts receive the sign of x.

     nextafter() returns the next representable double-precision floating-
     point value following x in the direction of y. Thus, if y is less than
     x, nextafter() returns the largest representable floating-point number
     less than x.




Page 1                       Reliant UNIX 5.44                Printed 11/98

frexp(3C)                                                         frexp(3C)

RESULT
     The frexp() function returns the value x, such that x is a double with
     magnitude in the interval [½, 1) or 0, and num equals x times 2 raised
     to the power *exp. If num is 0, both parts of the result are 0. If num
     is NaN, NaN is returned, errno may be set to EDOM and the value of
     *exp is unspecified. If num is +Inf, num is returned, errno may be set
     to EDOM and the value of *exp is unspecified.

     If ldexp() causes an overflow - and when the -kansi or -kosi compila-
     tion options were used -, HUGEVAL (defined in math.h) is returned
     (according to the sign of x), and errno is set to ERANGE. [When the
     -kcc (default) compilation option is used, HUGE is returned instead of
     HUGEVAL.] If ldexp() would cause underflow, zero is returned and
     errno is set to ERANGE. If the value of x is NaN, then ldexp() returns
     NaN and may set errno to EDOM.

     Upon successful completion, the scalb() function returns x * r^n. If
     the correct value would overflow, scalb() returns +HUGEVAL (according
     to the sign of x) and sets errno to ERANGE. If the correct value would
     underflow, scalb() returns 0 and sets errno to ERANGE. The scalb()
     function returns x when x is +Inf. If x or n is NaN, then scalb()
     returns NaN and may set errno to EDOM.

     Upon successful completion, logb() returns the exponent of x. If x is
     0.0, logb() returns -HUGEVAL and sets errno to EDOM. If x is +Inf,
     logb() returns +Inf. If x is NaN, logb() returns NaN and may set errno
     to EDOM. Upon successful completion, ilogb() returns the exponent part
     of x. If x is 0 or NaN, then ilogb() returns INTMIN. If x is +Inf,
     then ilogb() returns INTMAX.

     If input x to nextafter() is positive or negative infinity, that input
     is returned and errno is set to EDOM. The overflow and inexact excep-
     tions are signaled when input x is finite, but the result of
     nextafter(x, y) is not. The underflow and inexact exceptions are sig-
     naled when nextafter(x, y) lies strictly between +2^-1022. In both
     cases errno is set to ERANGE.

NOTES
     The function modff() can be used in ANSI mode only.

SEE ALSO
     cc(1), math(5).












Page 2                       Reliant UNIX 5.44                Printed 11/98

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026