std.complex

Dmitry Olshansky dmitry.olsh at gmail.com
Sun Nov 24 10:14:14 PST 2013


24-Nov-2013 22:03, Shammah Chancellor пишет:
> On 2013-11-24 18:00:45 +0000, Andrei Alexandrescu said:
>
>> On 11/24/13 9:54 AM, Joseph Rushton Wakeling wrote:
>>> On 23/11/13 08:43, Ali Çehreli wrote:
>>>> 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
>>>
>>> It's because 0.0L * (-real.infinity) evaluates to nan.
>>
>> Has this been submitted as a bug report?
>>
>> Andrei
>
> It's more a fundamental problem with a complex type in general.   C++
> has this issue as well.   You need a purely imaginary type with the
> appropiate operations between Complex and Imaginary defined.
>

Can't it just check for the real part being exactly zero and special- 
case multiplication for that?

-- 
Dmitry Olshansky


More information about the Digitalmars-d mailing list