The crealf function is part of the <complex.h> header file in C. It is used to return the real part of a complex number of type float. The function takes in a single parameter: a float complex number.
A complex number has a real and an imaginary part.
The illustration below shows how crealf works:
The crealf function is defined as follows:
float crealf(float complex z);
It takes in a single parameter of type float complex.
The following code snippet shows how we can use the crealf function. The code below outputs the real part of the complex number:
#include <stdio.h> // Including header file for printf function#include <complex.h> // Including header file for crealf functionint main(){float complex z = 2.0 + 7.0*I; // assign value to variableprintf("The real part is %f", crealf(z));return 0;}
crealf,crealandcreallare similar functions.
crealf takes a float complex number and returns itsfloat realcreal takes a double complex number and returns its double realcreall takes a long double complex number and returns its long double realFree Resources