std::modf,std::modff,std::modfl (3) - Linux Manuals
std::modf,std::modff,std::modfl: std::modf,std::modff,std::modfl
NAME
std::modf,std::modff,std::modfl - std::modf,std::modff,std::modfl
Synopsis
Defined in header <cmath>
float modf ( float x, float* iptr );
float modff( float x, float* iptr ); (since C++11)
double modf ( double x, double* iptr ); (1) (2)
long double modf ( long double x, long double* iptr ); (3)
long double modfl( long double x, long double* iptr ); (since C++11)
1-3) Decomposes given floating point value x into integral and fractional parts, each having the same type and sign as x. The integral part (in floating-point format) is stored in the object pointed to by iptr.
Parameters
x - floating point value
iptr - pointer to floating point value to store the integral part to
Return value
If no errors occur, returns the fractional part of x with the same sign as x. The integral part is put into the value pointed to by iptr.
The sum of the returned value and the value stored in *iptr gives x (allowing for rounding)
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 x is ±0, ±0 is returned, and ±0 is stored in *iptr.
* If x is ±∞, ±0 is returned, and ±∞ is stored in *iptr.
* If x is NaN, NaN is returned, and NaN is stored in *iptr.
* The returned value is exact, the_current_rounding_mode is ignored
Notes
This function behaves as if implemented as follows:
Example
Compares different floating-point decomposition functions
// Run this code
Possible output:
See also
trunc
truncf
truncl nearest integer not greater in magnitude than the given value
(C++11)
(C++11)
(C++11)