What is fmodl in C?
Overview
The fmodl() function in C performs the division operation of two input arguments. In mathematical notation, fmodl() performs the function of . The fmodl() function in C is defined in the <math.h> header file.
To use the fmodl() function, you must include the <math.h> library at the beginning of your code as shown below:
#include<math.h>
The fmodl() function is defined as below in the <math.h> header file:
long double fmodl( long double x, long double y );
Parameters
The fmodl() function takes two arguments ( and ) of type long double as input.
Return value
The fmodl() function returns the remainder if divides . The return value is of type long double.
Different values of and can result in varying results and errors:
- If but does not, the return value will be .
- If is and is a legitimate number, the return value will be
Not a Number (NaN). - If is and is a legitimate number, the return value will be
NaN. - If either or is
NaN, the return value will also beNaN.
Example
Below is an example of how you can use fmodl():
#include<stdio.h>#include<math.h>int main() {printf("4.2/2 = %Lf\n", fmodl(4.2,2));return 0;}
Explanation
The fmodl() function has been given the arguments such that and . The function divides and returns the result of this division.
Free Resources