Parameters: Break Into Fractional and Integral Parts
Parameters: Break Into Fractional and Integral Parts
Not logged in
C++
Information
Tutorials
Reference
Articles
Forum
function
Reference
C library: modf <cmath> <ctgmath>
<cassert> (assert.h)
C90 C99 C++98 C++11
<cctype> (ctype.h)
<cerrno> (errno.h) double modf (double x , double* intpart);
<cfenv> (fenv.h)
float modf (float x , float* intpart);
long double modf (long double x, long double* intpart);
<cfloat> (float.h)
double modf (T x , double* intpart); // additional overloads
<cinttypes> (inttypes.h)
<ciso646> (iso646.h) Break into fractional and integral parts
<climits> (limits.h) Breaks x into an integral and a fractional part.
<clocale> (locale.h)
<cmath> (math.h) The integer part is stored in the object pointed by intpart, and the fractional part is returned by the function.
<csetjmp> (setjmp.h)
<csignal> (signal.h) Both parts have the same sign as x.
<cstdarg> (stdarg.h)
<cstdbool> (stdbool.h) C++11
<cstddef> (stddef.h) Additional overloads are provided in this header (<cmath>) for the integral types: These overloads effectively cast x to
<cstdint> (stdint.h) a double before calculations (defined for T being any integral type).
<cstdio> (stdio.h)
<cstdlib> (stdlib.h)
<cstring> (string.h) Parameters
<ctgmath> (tgmath.h)
<ctime> (time.h) x
<cuchar> (uchar.h) Floating point value to break into parts.
<cwchar> (wchar.h)
intpart
<cwctype> (wctype.h) Pointer to an object (of the same type as x) where the integral part is stored with the same sign as x.
Containers:
Input/Output:
Multi-threading:
Other: Return Value
The fractional part of x, with the same sign.
<cmath> (math.h)
functions:
abs Example
acos
acosh
1 /* modf example */
2 #include <stdio.h> /* printf */
asin
3 #include <math.h> /* modf */
asinh
4
atan 5 int main ()
atan2 6 {
atanh 7 double param, fractpart, intpart;
cbrt 8
ceil 9 param = 3.14159265;
copysign 10 fractpart = modf (param , &intpart);
cos
11 printf ("%f = %f + %f \n", param, intpart, fractpart);
12 return 0;
cosh
13 }
erf
erfc
exp
Output:
exp2
expm1
3.141593 = 3.000000 + 0.141593
fabs
fdim
floor
fma
See also
fmax ldexp Generate value from significand and exponent (function )
fmin
frexp Get significand and exponent (function )
fmod
fpclassify
frexp
hypot
ilogb
isfinite
isgreater
isgreaterequal
isinf
isless
islessequal
islessgreater
isnan
isnormal
isunordered
ldexp
lgamma
llrint
llround
log
log10
log1p
log2
logb
lrint
lround
modf
nan
nanf
nanl
nearbyint
nextafter
nexttoward
pow
remainder
remquo
rint
round
scalbln
scalbn
signbit
sin
sinh
sqrt
tan
tanh
tgamma
trunc
macro constants:
HUGE_VAL
HUGE_VALF
HUGE_VALL
INFINITY
math_errhandling
NAN
types:
double_t
float_t