On 11/22/2013 09:22 PM, Craig Dillabaugh wrote:

> On Saturday, 23 November 2013 at 04:37:19 UTC, Shammah Chancellor wrote:
>> //Hijack
>>
>> http://digitalmars.com/d/1.0/cppcomplex.html
>>
>>> • Consider the formula (1 - infinity*i) * i which should produce
>>> (infinity + i). However, if instead the second factor is (0 + i)
>>> rather than just i, the result is (infinity + NaN*i), a spurious NaN
>>> was generated.
>>> • A distinct imaginary type preserves the sign of 0, necessary for
>>> calculations involving branch cuts.
>>
>> Is this stuff no longer an issue?
>>
>> -Shammah
>
> I believe D used to have builtin complex types, back in the old days.
> They have been removed (deprecated?)

It still compiles.

> and replaced by the library type
> std.complex.
>
> At least that is my understanding.

And it makes what Shammah Chancellor quoted even more interesting. cdouble and idouble still work correctly but std.complex produces "incorrect" result:

import std.stdio;
import std.complex;

void main()
{
    writeln(complex(1.0L, -real.infinity) * complex(0.0, 1.0L));
    writeln((1L - ireal.infinity) * 1i);
}


The output:

inf-nani    <-- "incorrect" according to the quoted page
inf+1i      <-- correct

>
> Craig
>

Ali

Reply via email to