std::scalbn,std::scalbnf,std::scalbnl,std::scalbln,std::scalblnf,std::scalblnl (3) - Linux Manuals
std::scalbn,std::scalbnf,std::scalbnl,std::scalbln,std::scalblnf,std::scalblnl: std::scalbn,std::scalbnf,std::scalbnl,std::scalbln,std::scalblnf,std::scalblnl
NAME
std::scalbn,std::scalbnf,std::scalbnl,std::scalbln,std::scalblnf,std::scalblnl - std::scalbn,std::scalbnf,std::scalbnl,std::scalbln,std::scalblnf,std::scalblnl
Synopsis
Defined in header <cmath>
float scalbn ( float x, int exp ); (1) (since C++11)
float scalbnf( float x, int exp );
double scalbn ( double x, int exp ); (2) (since C++11)
long double scalbn ( long double x, int exp ); (3) (since C++11)
long double scalbnl( long double x, int exp );
double scalbn ( IntegralType x, int exp ); (4) (since C++11)
float scalbln ( float x, long exp ); (5) (since C++11)
float scalblnf( float x, long exp );
double scalbln ( double x, long exp ); (6) (since C++11)
long double scalbln ( long double x, long exp ); (7) (since C++11)
long double scalblnl( long double x, long exp );
double scalbln ( IntegralType x, long exp ); (8) (since C++11)
1-3,5-7) Multiplies a floating point value x by FLT_RADIX raised to power exp.
4,8) A set of overloads or a function template accepting an argument of any integral_type. Equivalent to (2) or (6) (the argument is cast to double).
Parameters
x - floating point value
exp - integer value
Return value
If no errors occur, x multiplied by FLT_RADIX to the power of arg (x×FLT_RADIXexp
) is returned.
If a range error due to overflow occurs, ±HUGE_VAL, ±HUGE_VALF, or ±HUGE_VALL is returned.
If a range error due to underflow occurs, the correct result (after rounding) is returned.
Error handling
Errors are reported as specified in math_errhandling
If the implementation supports IEEE floating-point arithmetic (IEC 60559),
* Unless a range error occurs, FE_INEXACT is never raised (the result is exact)
* Unless a range error occurs, the_current_rounding_mode is ignored
* If x is ±0, it is returned, unmodified
* If x is ±∞, it is returned, unmodified
* If exp is 0, then x is returned, unmodified
* If x is NaN, NaN is returned
Notes
On binary systems (where FLT_RADIX is 2), std::scalbn is equivalent to std::ldexp.
Although std::scalbn and std::scalbln are specified to perform the operation efficiently, on many implementations they are less efficient than multiplication or division by a power of two using arithmetic operators.
The function name stands for "new scalb", where scalb was an older non-standard function whose second argument had floating-point type.
The scalbln function is provided because the factor required to scale from the smallest positive floating-point value to the largest finite one may be greater than 32767, the standard-guaranteed INT_MAX. In particular, for the 80-bit long double, the factor is 32828.
The GNU implementation does not set errno regardless of math_errhandling
Example
// Run this code
Possible output:
See also
frexp
frexpf
frexpl decomposes a number into significand and a power of 2
(C++11)
(C++11)
ldexp
ldexpf
ldexpl multiplies a number by 2 raised to a power
(C++11)
(C++11)