Complex numbers are harder to use than in C
Marduk via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Nov 19 01:38:38 PST 2016
Dear all,
I just discovered D and I am translating some numerical code I
wrote in C. I was surprised to learn that there are at least two
things that are easier in C than in D:
+ Writing complex numbers
C: complex double z = 2.0 + 3.0*I;
D: auto z = complex(2.0, 3.0);
+ Arrays of complex numbers
C: complex double a[2][2] = {{1.0*I, 0.0}, {0.0, 1.0*I}};
D: Complex!double[2][2] a = [[complex(0.0, 1.0), complex(0.0)],
[complex(0.0), complex(0.0, 1.0)]];
The difference is that D is more verbose. Am I missing something?
Can we have C's behaviour in D?
More information about the Digitalmars-d-learn
mailing list