C library functions - modf ()
description
C library functionsdouble modf (double x, double * integer) Returns the value of the fractional part (part after the decimal point), and set the integer to integer part.
statement
Here is () statement modf function.
double modf(double x, double *integer)
parameter
- x - floating-point value.
- integer - a pointer to an object, the object stores the integer part.
return value
This function returns the fractional part of x, and x symbols the same.
Examples
The following example demonstrates modf () function is used.
#include<stdio.h> #include<math.h> int main () { double x, fractpart, intpart; x = 8.123456; fractpart = modf(x, &intpart); printf("整数部分 = %lf\n", intpart); printf("小数部分 = %lf \n", fractpart); return(0); }
Let's compile and run the above program, which will result in the following:
整数部分 = 8.000000 小数部分 = 0.123456