Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   std::complex<long double> division (http://www.velocityreviews.com/forums/t460019-std-complex-long-double-division.html)

Fredy Halter 01-24-2007 01:56 PM

std::complex<long double> division
 
the following code is not working:

std::complex<long double> x(1.,1.);
std::complex<long double> result(0.,0.);

result = 1./x;

std::cout << "x = " << x << std::endl;
std::cout << "r = " << result << std::endl;


with std::complex<double> it works. anyone knows how to get rid of this?
i need long double for my calculations. thx.

Ondra Holub 01-24-2007 02:02 PM

Re: std::complex<long double> division
 

Fredy Halter napsal:
> the following code is not working:
>
> std::complex<long double> x(1.,1.);
> std::complex<long double> result(0.,0.);
>
> result = 1./x;
>
> std::cout << "x = " << x << std::endl;
> std::cout << "r = " << result << std::endl;
>
>
> with std::complex<double> it works. anyone knows how to get rid of this?
> i need long double for my calculations. thx.


Write it this way:
result = 1.L / x;

1. is double, 1.L is long double


Rolf Magnus 01-24-2007 02:03 PM

Re: std::complex<long double> division
 
Fredy Halter wrote:

> the following code is not working:
>
> std::complex<long double> x(1.,1.);
> std::complex<long double> result(0.,0.);
>
> result = 1./x;
>
> std::cout << "x = " << x << std::endl;
> std::cout << "r = " << result << std::endl;
>
>
> with std::complex<double> it works. anyone knows how to get rid of this?


Get rid of what? Define "not working".



Lionel B 01-24-2007 02:08 PM

Re: std::complex<long double> division
 
On Wed, 24 Jan 2007 14:56:08 +0100, Fredy Halter wrote:

> the following code is not working:


(In future please define "not working" and supply complete compilable code)

> std::complex<long double> x(1.,1.);
> std::complex<long double> result(0.,0.);
>
> result = 1./x;


result = std::complex<long double>(1.)/x;

There is no operator / (at least not on my system) that takes a lhs of
type double and a rhs of type std::complex<long double>.

[...]

--
Lionel B

Kai-Uwe Bux 01-24-2007 02:14 PM

Re: std::complex<long double> division
 
Fredy Halter wrote:

> the following code is not working:
>
> std::complex<long double> x(1.,1.);
> std::complex<long double> result(0.,0.);
>
> result = 1./x;


result = 1.0L / x;

>
> std::cout << "x = " << x << std::endl;
> std::cout << "r = " << result << std::endl;
>
>
> with std::complex<double> it works.


The type of the floating point literal needs to match the type for the
complex.

[snip]


Best

Kai-Uwe Bux



All times are GMT. The time now is 09:36 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.