AnsweredAssumed Answered

Integer addition doesn t seem to work

Question asked by Julien Gingras on May 1, 2010
Latest reply on May 4, 2010 by bigmac

Hi

Im using codewarrior 6.3 

and a MC9s08QE32

 

When I do the following 

    cX = cM * 2;
    cY = cX + (((cM+1)*3)/5);
    cX = cY + ((sTime.cYear-i)/4);
    cY = cX - ((sTime.cYear-i)/100);
    cX = cY + ((sTime.cYear-i)/400);
    
    cY = (cX + (sTime.cYear-i));
    cX = cY + 2;
    cX %= 7;
    sTime.cDayofWeek = (char)cX;

 

where cY,cX and stime.cYear are all interger (unsigned for cyear)

Im using debugger with a openbdm

those two line doesnt change variable content

    cY = (cX + (sTime.cYear-i));
    cX = cY + 2;

but cX %=7 does work (but the final result is wrong due to 2 addition failing to add :smileyfrustrated:

 

can someone point me what im doing wrong there?

Outcomes