Do I have to cast double to cdouble everywhere?

John Travers jtravs at gmail.com
Fri Aug 6 06:23:18 PDT 2010


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.

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.

Is there a simple solution to this without covering all my code with casts?

Thanks for any help!

Regards,
John



More information about the Digitalmars-d-learn mailing list