J
John
Hi all...
Either I'm doing really something really stupid - or maybe there is
some bug somewhere (optimizing?). In a function I have:
int x1, y1, x2, y2;
float dR, dX, dY;
dR = (state.cam1x - x1) - (state.cam2x - x2);
dX = 0.5 * ((state.cam1x - x1) + (state.cam2x - x2));
dY = 0.5 * ((state.cam1y - y1) + (state.cam2y - y2));
printf("%d %d %d %d\n", state.cam1x, state.cam1y, state.cam2x,
state.cam2y);
printf("%d %d %d %d\n", x1, y1, x2, y2);
printf("%f %f %f\n", dX, dY, dR);
(state.xxx are declared globally, outside the function as integers)
I get:
342 224 343 225
339 215 340 215
nan nan nan
No warnings when compiling. I've looked into FAQs and other texts, no
luck...
John
Either I'm doing really something really stupid - or maybe there is
some bug somewhere (optimizing?). In a function I have:
int x1, y1, x2, y2;
float dR, dX, dY;
dR = (state.cam1x - x1) - (state.cam2x - x2);
dX = 0.5 * ((state.cam1x - x1) + (state.cam2x - x2));
dY = 0.5 * ((state.cam1y - y1) + (state.cam2y - y2));
printf("%d %d %d %d\n", state.cam1x, state.cam1y, state.cam2x,
state.cam2y);
printf("%d %d %d %d\n", x1, y1, x2, y2);
printf("%f %f %f\n", dX, dY, dR);
(state.xxx are declared globally, outside the function as integers)
I get:
342 224 343 225
339 215 340 215
nan nan nan
No warnings when compiling. I've looked into FAQs and other texts, no
luck...
John