C Reference function modf()

Usage of modf():

double modf(double x, double *integer);


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():


	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. You can leave a response, or trackback from your own site. Tweet This! Tweet This! or use to share this post with others.

Leave a Reply: