HPlogo HP-UX Reference > L

ldexp(3M)

HP-UX 11i Version 2: December 2007 Update
» 

Technical documentation

 » Table of Contents

 » Index

NAME

ldexp(), ldexpf(), ldexpl(), ldexpw(), ldexpq() — scale exponent of a floating-point number

SYNOPSIS

#include <math.h>

double ldexp(double x, int exp);

Itanium(R)-based System Only

float ldexpf(float x, int exp);

long double ldexpl(long double y, int exp);

extended ldexpw(extended x, int exp);

quad ldexpq(quad x, int exp);

DESCRIPTION

The ldexp() function computes the quantity x* 2exp.

ldexp() computes the same value as scalbn().

Itanium-based System Only

ldexpf() is a float version of ldexp(); it takes a float first argument and returns a float result.

ldexpl() is a long double version of ldexp(); it takes a long double first argument and returns a long double result.

ldexpw() is an extended version of ldexp(); it takes a extended first argument and returns an extended result.

ldexpq() is equivalent to ldexpl() on HP-UX systems.

USAGE

To use (for Itanium-based systems) ldexpf(), compile either with the default -Ae option or with the -Aa option.

To use (for Itanium-based systems) ldexpl(), ldexpw(), or ldexpq(), compile either with the default -Ae option or with the -Aa and -D_HPUX_SOURCE options.

To use (for Itanium-based systems) ldexpw() or ldexpq(), compile also with the -fpwidetypes option.

To use any of these functions, make sure your program includes <math.h>, and link in the math library by specifying -lm on the compiler or linker command line.

For more information, see the HP-UX Floating-Point Guide.

RETURN VALUE

Upon successful completion, the ldexp() function returns x* 2exp.

If x is ±INFINITY, zero, or a NaN, ldexp() returns x.

ldexp() returns a properly signed infinity (equal to ±HUGE_VAL) in lieu of a value whose magnitude is too large, and raises the overflow and inexact exceptions.

ldexp() raises the underflow and inexact exceptions whenever a result is tiny (essentially denormal or zero) and thereby suffers loss of accuracy, and may raise those exceptions if the result is merely tiny.

ERRORS

If the correct value would overflow, ldexp() sets errno to [ERANGE].

Itanium-based System Only

HP-UX libm functions on Itanium-based systems do not set errno by default. For errno setting, compile with the +Olibmerrno option.

STANDARDS CONFORMANCE

ldexp() : SVID3, XPG4.2, ANSI C, ISO/IEC C99 (including Annex F, ``IEC 60559 floating-point arithmetic'')

ldexpf(), ldexpl() ISO/IEC C99 (including Annex F, ``IEC 60559 floating-point arithmetic'')