About complex (complex types) and imaginary (imaginary types) in C languages

Source: Internet
Author: User
Tags square root

About complex (complex types) and imaginary (imaginary types) in C languages

In fact, the plural complex here is the plural of mathematics, including the real part and the imaginary part of two parts, such as: X=2.1+6i, the following detailed introduction.

C99 new Complex Type (_complex) and imaginary type (_imaginary). Simply put, C99 offers three complex types: float _complex,double _complex, and long double _complex. For a variable of type float _complex, it contains two values of type float, one for the real part of the complex number, and another to represent the imaginary part (imaginary parts). Similarly, a double _complex contains two values of type double. C99 also offers three imaginary types: float _imaginary,double _imaginary, and long double _imaginary. Imaginary type only imaginary part, no real part.

With the standard header file Complex.h, we can use complex to represent the _complex, use the imaginary to represent the _imaginary, and use I to represent the imaginary unit I, which is the square root of 1. For example:

#include <complex.h>

Double _complex x = 5.2;

Double Complex y = 5.0 * I;

Double complex z = 5.2–5.0 * I;

Note: The _complex type is optional for stand-alone environments (freestanding environment). Optionally, it is not mandatory to support this type. The so-called standalone environment means that C programs can run without an operating system. The _imaginary type is optional in any environment. The current compiler is not very good at both types of support, so there is no more in-depth discussion of these two types.

Transferred from http://blog.csdn.net/zxxssdsd/article/details/9948817, only for individual learning use.

About complex (complex types) and imaginary (imaginary types) in C languages

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.