Best way to "convert" a real to ireal

Christian Kamm kamm.incasoftware at shift-at-left-and-remove-this.de
Fri Sep 14 02:28:40 PDT 2007


> I just had a brainwave regarding the imaginary part of creal -
> 
> ---
> creal c = 1.0 + 1.0i;
> ireal i = cast(ireal)c;
> ---
> 
> does exactly what I want. Isn't it just obvious in hindsight...

For your peace of mind: with optimizations enabled, the cast(ireal) and
the .im * i seem to produce exactly the same code.

Cheers,
Christian


More information about the Digitalmars-d-learn mailing list