Connecting Tech Pros Worldwide Forums | Help | Site Map

std::complex<long double> division

Fredy Halter
Guest
 
Posts: n/a
#1: Jan 24 '07
the following code is not working:

std::complex<long doublex(1.,1.);
std::complex<long doubleresult(0.,0.);

result = 1./x;

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


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

Ondra Holub
Guest
 
Posts: n/a
#2: Jan 24 '07

re: std::complex<long double> division



Fredy Halter napsal:
Quote:
the following code is not working:
>
std::complex<long doublex(1.,1.);
std::complex<long doubleresult(0.,0.);
>
result = 1./x;
>
std::cout << "x = " << x << std::endl;
std::cout << "r = " << result << std::endl;
>
>
with std::complex<doubleit 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
Guest
 
Posts: n/a
#3: Jan 24 '07

re: std::complex<long double> division


Fredy Halter wrote:
Quote:
the following code is not working:
>
std::complex<long doublex(1.,1.);
std::complex<long doubleresult(0.,0.);
>
result = 1./x;
>
std::cout << "x = " << x << std::endl;
std::cout << "r = " << result << std::endl;
>
>
with std::complex<doubleit works. anyone knows how to get rid of this?
Get rid of what? Define "not working".


Lionel B
Guest
 
Posts: n/a
#4: Jan 24 '07

re: std::complex<long double> division


On Wed, 24 Jan 2007 14:56:08 +0100, Fredy Halter wrote:
Quote:
the following code is not working:
(In future please define "not working" and supply complete compilable code)
Quote:
std::complex<long doublex(1.,1.);
std::complex<long doubleresult(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
Guest
 
Posts: n/a
#5: Jan 24 '07

re: std::complex<long double> division


Fredy Halter wrote:
Quote:
the following code is not working:
>
std::complex<long doublex(1.,1.);
std::complex<long doubleresult(0.,0.);
>
result = 1./x;
result = 1.0L / x;
Quote:
>
std::cout << "x = " << x << std::endl;
std::cout << "r = " << result << std::endl;
>
>
with std::complex<doubleit works.
The type of the floating point literal needs to match the type for the
complex.

[snip]


Best

Kai-Uwe Bux

Closed Thread