I wonder if anyone can sort this silly problem out for me. I'm new to C++, having mostly programmed in BASIC.
Have a look at the following code:
///////////////// Code start
float grad = (y2-y1)/(x2-x1);
int t = i-x1;
float m = t * (0.25);
//float m = (t * (1/4));
float n = m + y1;
int j = (integer (n));
DrawPixel(screen, i, j, r, g, b);
///////////////// Code end
Note the // commented line in the middle of the code. For some reason, when the code is in its current state, I get expected results. But when the commented line is substituted in for the (apparently equivalent, or so I thought) line above it, the variable m seems to be equal to zero.
Why does C++ think 0.25 is not equal to 1/4?!
Any help much appreciated.