www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.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