English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
C Library Function double modf(double x, double *integer) Returns the fractional part (the part after the decimal point), and sets integer to the integer part.
Declaration of modf() function
double modf(double x, double *integer)
x -- Floating-point value.
integer -- A pointer to an object that stores the integer part.
This function returns the fractional part of x, with the same sign as x.
The following example demonstrates the usage of the modf() function.
#include<stdio.h> #include<math.h> int main() { double x, fractpart, intpart; x = 9.87654321; fractpart = modf(x, &intpart); printf("Integer part = %lf\n", intpart); printf("Decimal Part = %lf \n", fractpart); return(0); }
Let's compile and run the above program, which will produce the following result:
Integer Part = 9.000000 Decimal Part = 0.876543