[Cfp-interest 3270] Re: Specification of complex operators
Damian McGuckin
damianm at esi.com.au
Wed Sep 11 23:13:44 PDT 2024
Hi Paul,
On Thu, 12 Sep 2024, Paul Zimmermann wrote:
>> Shouldn't these yield a number whose real and imaginary components are
>> both an infinity?
>
> yes this is what we get:
>
> libm gives (-inf,-nan)
> mpc gives (-inf,-inf)
>
> thus we consider the error is infinite in this case.
> A complex multiply should never yield NaN (if no NaN in the inputs).
I whipped up a quick example in Chapel. I use a Chapel compiler which uses
the CLANG/LLVM backend:
// p, q and t are complex
proc main64 // done in 64-bit floating point
{
const p = -0x1.80a55ep+0 + 0x1.1bfep+80i;
const q = 0x1.ap+64 - 0x1.54c296p+127i;
const t = p * q;
writeln(p);
writeln(q);
writeln(t);
}
proc main32 // done in 32-bit floating point
{
const p = -0x1.80a55ep+0:real(32) + 0x1.1bfep+80:imag(32);
const q = 0x1.ap+64:real(32) - 0x1.54c296p+127:imag(32);
const t = p * q;
writeln(p, " ", p.type:string);
writeln(q, " ", q.type:string);
writeln(t, " ", t.type:string);
}
proc main
{
main64;
main32;
}
The value of t (coming from main32 using 32-bit floating point) is
inf + inf i
which is Chapel-speak for
INFINITY + INFINITY * I
The Chapel compiler can be built with a GCC backend. I will ask somebody
who has done this what result they see with Chapel in that case.
Thanks - Damian
More information about the Cfp-interest
mailing list