www.digitalmars.com         C & C++   DMDScript  

c++ - Complex type bug

#include <complex.h>
#include <stdio.h>

void f(long double complex a, long double complex b, long double complex 
c, long double complex d)
{
  long double complex a_, b_, u, v;

  //a_ = conjl(a);
  //b_ = conjl(b);

  a_ = creall(a) - I*cimagl(a);
  b_ = creall(b) - I*cimagl(b);

  u = (d - c)*(a_*b - a*b_);
  v = (a_*b - a*b_)*(d - c);

  printf("u = (%Lg,\t%Lg)\n", creall(u), cimagl(u));
  printf("v = (%Lg,\t%Lg)\n", creall(v), cimagl(v));
}

int main(void){
  f(410.891l + 291.848l*I,
    476.607l + 294.149l*I,
    327.0l + 360.0l*I,
    439.0l + 192.0l*I);

  return 0;
}

dmc cbug.c -o & cbug
u = (-nan,      -nan)
v = (-6.1265e+06,       -4.08433e+06)

DMC v8.47

Brian
Feb 03 2006