Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

c

What is creall in C?

Hassaan Waqar

The creall function is part of the <tgmath.h> header file in C.

It is used to return the real part of a complex number of type long double. The function takes in a single parameter: a long double complex number.

A complex number has a real and an imaginary part.

The illustration below shows how creall works:

How does creall work?

Declaration

The creall function is defined as follows:

long double creall(long double complex z);

It takes in a single parameter of type long double complex.

Example

The following code snippet shows how we can use the creall function. The code below outputs the real part of the complex number:

#include <stdio.h> // Including header file for printf function
#include <tgmath.h> // Including header file for creall function

int main(){

  long double complex z = 7.0 + 3.0*I; // assign value to variable
  printf("The real part is %Lf", creall(z));
  return 0;
}

creall, creal and crealf are similar functions.

  • creall takes a long double complex number and returns its long double real
  • creal takes a double complex number and returns its double real
  • crealf takes a float complex number and returns itsfloat real

RELATED TAGS

c

CONTRIBUTOR

Hassaan Waqar
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring