C Reference function modf()

Usage of modf():

double modf(double x, double *integer);

Parameters:

There is no range limit on the argument.

Return value:

The returned value is the fraction component (that is the part after the decimal),
and sets integer to the integer component. There is no range limit on the return value.

Source code example of modf():


#include<stdio.h>
#include<math.h>

main()
{
	double input, fractional_part, integer_part;
	input = 3.14159265;
	fractional_part = modf (input , &integer_part);
	printf ("%lf = %lf + %lf \n", input, integer_part, fractional_part);
	return 0;
}

Output of the modf example program above:


	3.141593 = 3.000000 + 0.141593

This entry was posted in C Reference math.h Functions. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed. Tweet This! Tweet This! or use to share this post with others.

Comments are closed.