Java to D
bearophile
bearophileHUGS at lycos.com
Fri Jan 4 07:03:03 PST 2008
Jeferson Andrade:
> //= new creal(Math.cos(kth), Math.sin(kth));
> wk1 = cos(kth);
> wk2 = cast(ireal) sin(kth);
> wk = wk1 + wk2;
D complex numbers are tricky...
import std.stdio, std.math;
void main() {
int kth = 3;
auto wk1 = cos(kth);
auto wk2 = cast(ireal) sin(kth);
auto wk = wk1 + wk2;
writefln(wk);
auto wk3 = cos(kth) + sin(kth) * 1i;
writefln(wk3);
}
It prints:
-0.989992+0i
-0.989992+0.14112i
Bye,
bearophile
More information about the Digitalmars-d
mailing list