John Travers wrote:
Hi,
I'm investigating if D would be useful to me as a numerical programming
language to replace my current mix of fortran and python.
Welcome! There are quite a few of us who are numerical programmers here,
and it's one of D's target areas.
I'm stuck with a problem which seems odd to me:
cdouble c1;
c1 = 2.0;
complains:
Error: cannot implicitly convert expression (2) of type double to cdouble
The only way I can find to solve this is by doing:
c1 = cast(cdouble)2.0;
This will drive me crazy, many numeric codes need to multiply complex numbers,
or assign to them, with real numbers. This problem also occurs with imaginary
numbers.
Unfortunately we had to disable implicit casts double->cdouble, because
it causes problems with function overloading.
So you need to explicitly add the imaginary part.
c1 = 2.0 + 0.0i;