[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]
Base Operating System and Extensions Technical Reference, Volume 1

frexp, frexpl, ldexp, ldexpl, modf, or modfl Subroutine

Purpose

Manipulates floating-point numbers.

Library

Standard C Library (libc.a)

Syntax

#include <math.h>
double frexp (Value, Exponent)
double Value;
int *Exponent;
long double frexpl (Value, Exponent)
long double Value;
int Exponent;
double ldexp (Mantissa, Exponent)
double Mantissa;
int Exponent ;
long double ldexpl (Mantissa, Exponent)
long double Mantissa;
int Exponent;
double modf (Value, IntegerPointer)
double Value, *IntegerPointer;
long double modfl (Value, IntegerPointer)
long double Value, *IntegerPointer;

Description

Every nonzero number can be written uniquely as x * 2**n, where the mantissa (fractional part) x is in the range 0.5 <= |x| < 1.0, and the exponent n is an integer.

The frexp subroutine breaks a floating-point number into a normalized fraction and an integral power of 2. It stores the integer in the object pointed to by the Exponent parameter and returns the fraction part. The frexpl subroutine performs the same function for numbers in the long double data type.

The ldexp subroutine multiplies a floating-point number by an integral power of 2. The ldexpl subroutine performs the same function for numbers in the long double data type.

The modf subroutine breaks the Value parameter into an integral and fractional part, each of which has the same sign as the value. It stores the integral part in a double variable at the location pointed to by the IntegerPointer parameter. The modfl subroutine performs the same function for numbers in the long double data type.

Parameters

Value Specifies a double-precision floating-point value.
Exponent For the frexp subroutine, specifies an integer pointer to store the exponent; for the ldexp subroutine, specifies an integer value.
Mantissa Specifies a double-precision floating-point value.
IntegerPointer Specifies a pointer to the double variable in which to store the signed integral part.

Return Values

The frexp and frexpl subroutines return a value x such that x is in the range 0.5 <= |x| < 1.0 or is 0, and the Value parameter equals x * 2**(*Exponent). If the Value parameter is 0, the object pointed to by the *Exponent parameter and x are also 0. If the Value parameter is a NaN (not-a-number), x is a NaNQ, and the object pointed to by the *Exponent parameter is set to LONG_MIN. If the Value parameter is +INF, then +INF is returned and the object pointed to by the *Exponent parameter is set to INT_MAX. If the Value parameter is -INF, then -INF is returned and the object pointed to by the *Exponent parameter is set to INT_MIN.

The ldexp and ldexpl subroutines return the value x * 2**(Exponent).

The modf and modfl subroutines return the signed fractional part of the Value parameter and stores the signed integral part in the object pointed to by the IntegerPointer parameter. If the Value parameter is a NaN value, then a NaNQ value is returned, and a NaNQ is stored in the object pointed to by the IntegerPointer parameter. If the Value parameter is +/-INF, then +/- 0.0 is returned, and +/-INF is stored in the object pointed to by the IntegerPointer parameter.

Error Codes

If the result of the ldexp or ldexpl subroutine overflows, then +/- HUGE_VAL is returned, and the global variable errno is set to ERANGE.

If the result of the ldexp or ldexpl subroutine underflows, 0 is returned, and the errno global variable is set to a ERANGE value.

Implementation Specifics

These subroutines are part of Base Operating System (BOS) Runtime.

Related Information

The scanf, fscanf, or sscanf subroutine, sgetl or sputl subroutine.

Subroutines Overview in AIX Version 4.3 General Programming Concepts: Writing Programs.

128-Bit long Double Floating-Point Format in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.


[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]