std::frexp,std::frexpf,std::frexpl (3) - Linux Manuals
std::frexp,std::frexpf,std::frexpl: std::frexp,std::frexpf,std::frexpl
NAME
std::frexp,std::frexpf,std::frexpl - std::frexp,std::frexpf,std::frexpl
Synopsis
Defined in header <cmath>
float frexp ( float arg, int* exp );
float frexpf( float arg, int* exp ); (since C++11)
double frexp ( double arg, int* exp ); (1) (2)
long double frexp ( long double arg, int* exp );
long double frexpl( long double arg, int* exp ); (3) (since C++11)
double frexp ( IntegralType arg, int* exp ); (4) (since C++11)
1-3) Decomposes given floating point value arg into a normalized fraction and an integral power of two.
4) A set of overloads or a function template accepting an argument of any integral_type. Equivalent to (2) (the argument is cast to double).
Parameters
arg - floating point value
exp - pointer to integer value to store the exponent to
Return value
If arg is zero, returns zero and stores zero in *exp.
Otherwise (if arg is not zero), if no errors occur, returns the value x in the range (-1;-0.5], [0.5; 1) and stores an integer value in *exp such that x×2(*exp)
=arg
If the value to be stored in *exp is outside the range of int, the behavior is unspecified.
If arg is not a floating-point number, the behavior is unspecified.
Error handling
This function is not subject to any errors specified in math_errhandling.
If the implementation supports IEEE floating-point arithmetic (IEC 60559),
* If arg is ±0, it is returned, unmodified, and 0 is stored in *exp.
* If arg is ±∞, it is returned, and an unspecified value is stored in *exp.
* If arg is NaN, NaN is returned, and an unspecified value is stored in *exp.
* No floating-point exceptions are raised.
* If FLT_RADIX is 2 (or a power of 2), the returned value is exact, the_current_rounding_mode is ignored
Notes
On a binary system (where FLT_RADIX is 2), frexp may be implemented as
The function std::frexp, together with its dual, std::ldexp, can be used to manipulate the representation of a floating-point number without direct bit manipulations.
Example
Compares different floating-point decomposition functions
// Run this code
Possible output:
See also
ldexp
ldexpf
ldexpl multiplies a number by 2 raised to a power
(C++11)
(C++11)
logb
logbf
logbl extracts exponent of the number
(C++11)
(C++11)
(C++11)
ilogb
ilogbf
ilogbl extracts exponent of the number
(C++11)
(C++11)
(C++11)
modf
modff
modfl decomposes a number into integer and fractional parts
(C++11)
(C++11)