struct opCall makes a nan

dominik asd at asd.com
Sun Mar 23 16:58:21 PDT 2008


I'm confused by this:

struct vector3 {

  union {
   struct { float x, y, z; };
   struct { float r, g, b; };
   struct { float cell[3]; };
  };

}

struct plane {

  union {
   struct { vector3 N; float D; };
   struct { float cell[4]; };
  };

  plane opCall() {
   plane pl;
   N.x = 0.0f; N.y = 0.0f; N.z = 0.0f;
   D = 0.0f;
   return pl;
  };

}

and when I do this:

 plane plane_test;
 Stdout.formatln("{}", plane_test.N.x);

it prints out a nan, when it should be 0F, ofcourse - what am I doing wrong? 




More information about the Digitalmars-d-learn mailing list