_scalb, _scalbl

From RAD Studio
Jump to: navigation, search

Go Up to float.h Index


Header File

float.h

Prototype

double _scalb(double d, long exp);
long double _scalbl(long double ld, long exp);

Description

Scales the argument d by a power of 2.

_scalbl is the long double version; it takes a long double argument and returns a long double result.

Return Value

Returns an exponential value if successful. On overflow (depending on the sign of the argument), the function returns +/- HUGE_VAL; the ERRNO variable is set to ERANGE.

Portability

POSIX ANSI C ANSI C++ Win32 Win64 OS X
_scalb +
_scalbl +

Example

#include <float.h>

int _tmain(int argc, _TCHAR* argv[]) {
	double number;
	long exp;

	/* Request the number and exponent */
	printf("Enter the value and exponent: ");
	scanf("%lf %u", &number, &exp);

	/* Scale the number using */
	printf("Number * (2^Exp) = %lf\n", _scalb(number, exp));

	return 0;
}