C++::multiprecision::cpp_complex














































C++::multiprecision::cpp_complex



Header file #include<boost/multiprecision/cpp_complex.hpp>
<cpp_complex.hpp> is a header file or a function which is used to work with complex numbers.
The complex number has two parts real and imaginary
i.e.(real)+i(imag)
The benefits of this function is that it can be used to work with real part and imaginary part simultaneously which makes it more time compitable.
#include<iostream>
using namespace std;
main()
{
    complex s{1,2};
    cout<<"Complex number is "<<s<<endl;
    cout<<"Real part is "<<s.real()<<endl;
    cout<<"Imaginary is "<<s.imag()<<endl;
    cout<<"Square of the number is "<<s*s<<endl;
    return 0;
}
As mentioned above it can be used to work with real and imaginary part and for working with only real or imaginary part there are two function available in the library
1.obj.real();
2.obj.imag();



Comments