HPlogo HP-UX Reference > S

scalb(3M)

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

Technical documentation

 » Table of Contents

 » Index

NAME

scalb(), scalbf(), scalbl(), scalbw(), scalbq() — scale exponent of a radix-independent floating-point number

SYNOPSIS

#include <math.h>

double scalb(double x, double y);

Itanium(R)-based System Only

float scalbf(float x, float n);

long double scalbl(long double y, long double n);

extended scalbw(extended x, extended n);

quad scalbq(quad x, quad n);

DESCRIPTION

The scalb() function returns x * ry, where r is the radix of the machine's floating-point arithmetic. The radix r is 2 on all PA-RISC and Itanium-based systems.

Itanium-based System Only

scalbf() is a float version of scalb(); it takes float arguments and returns a float result.

scalbl() is a long double version of scalb(); it takes long double arguments and returns a long double result.

scalbw() is an extended version of scalb(); it takes extended arguments and returns an extended result.

scalbq() is equivalent to scalbl() on HP-UX systems.

USAGE

To use these functions, compile either with the default -Ae option or with the -Aa and -D_HPUX_SOURCE options.

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

Make sure your program includes <math.h>. Link in the math library by specifying -lm on the compiler or linker command line.

RETURN VALUE

scalb(-x, y) and -scalb(x, y) are equivalent.

If y is ±0, scalb() returns x.

If x is +0 and y is +INFINITY, scalb() returns a NaN and raises the invalid exception.

If x is +0 and y is an integer less than +INFINITY, scalb() returns +0.

If x is +INFINITY and y is an integer greater than -INFINITY, scalb() returns +INFINITY.

If x is finite and positive-signed and y is -INFINITY, scalb() returns +0.

If x is positive and y is +INFINITY, scalb() returns +INFINITY.

If x is +INFINITY and y is -INFINITY, scalb() returns a NaN.

If x or y is NaN, scalb() returns a NaN.

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

scalb() 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 or underflow, scalb() 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

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