int temp1,temp2,temp3;
temp1 = 199;
temp2 = 200;
temp3 = 199%temp2;
CString txt;
txt.Format(_T("temp3 = %d"),temp3);
AfxMessageBox(txt);
Output is 199 as expected.
#define WIDTH 100
#define BUFFERWIDTH 200
int temp1,temp2,temp3;
temp1 = 199;
temp2 = BUFFERWIDTH;
temp3 = 199%BUFFERWIDTH;
CString txt;
txt.Format(_T("temp3 = %d"),temp3);
AfxMessageBox(txt);
Output is 199 as expected.
#define WIDTH 100
#define BUFFERWIDTH 2*WIDTH
int temp1,temp2,temp3;
temp1 = 199;
temp2 = BUFFERWIDTH;
temp3 = 199%BUFFERWIDTH;
CString txt;
txt.Format(_T("temp3 = %d"),temp3);
AfxMessageBox(txt);
Output is 100…
Just wondering what is causing this 🙂
Read up about operator precedence, and note that you are saying
199 % 2 * 100..
.
.
or should I say,
(199 % 2) * 100…