<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>8-bit MicrocontrollersのトピックRe: Integer addition doesn t seem to work</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Integer-addition-doesn-t-seem-to-work/m-p/197098#M15826</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For an espression such as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;cX = (cDay + (cM + 1)*26/10 + K + K/4 + J/4 - 2*J) % 7;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;since all variables are integer, the result of any intermediate calculation will also be an integer value (with any remainder simply truncated).&amp;nbsp; Floating point values are only of consideration if one or more of the variables or constants is a floating point type.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 04 May 2010 13:37:47 GMT</pubDate>
    <dc:creator>bigmac</dc:creator>
    <dc:date>2010-05-04T13:37:47Z</dc:date>
    <item>
      <title>Integer addition doesn t seem to work</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Integer-addition-doesn-t-seem-to-work/m-p/197092#M15820</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;Im using codewarrior 6.3&amp;nbsp;&lt;/P&gt;&lt;P&gt;and a MC9s08QE32&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I do the following&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cX = cM * 2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cY = cX + (((cM+1)*3)/5);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cX = cY + ((sTime.cYear-i)/4);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cY = cX - ((sTime.cYear-i)/100);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cX = cY + ((sTime.cYear-i)/400);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cY = (cX + (sTime.cYear-i));&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cX = cY + 2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cX %= 7;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sTime.cDayofWeek = (char)cX;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;where cY,cX and stime.cYear are all interger (unsigned for cyear)&lt;/P&gt;&lt;P&gt;Im using debugger with a openbdm&lt;/P&gt;&lt;P&gt;those two line doesnt change variable content&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cY = (cX + (sTime.cYear-i));&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cX = cY + 2;&lt;/P&gt;&lt;P&gt;but cX %=7 does work (but the final result is wrong due to 2 addition failing to add &lt;A href="http://freescale.i.lithium.com/i/smilies/16x16_smiley-frustrated.gif"&gt;&lt;IMG alt=":smileyfrustrated:" class="emoticon emoticon-smileyfrustrated" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-frustrated.gif" title="Smiley Frustrated" /&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;can someone point me what im doing wrong there?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 01 May 2010 19:16:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Integer-addition-doesn-t-seem-to-work/m-p/197092#M15820</guid>
      <dc:creator>Juls</dc:creator>
      <dc:date>2010-05-01T19:16:43Z</dc:date>
    </item>
    <item>
      <title>Re: Integer addition doesn t seem to work</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Integer-addition-doesn-t-seem-to-work/m-p/197093#M15821</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;answered myself&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;declared long int and it work now&lt;/P&gt;&lt;P&gt;int is not 16 bit???&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BTW this is zeller's congruence&lt;/P&gt;&lt;P&gt;cM = sTime.cMonth;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Day of week&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(cM == 1)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cM = 13;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i++;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if(sTime.cMonth == 2)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cM = 14;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i++;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cX = sTime.cDay;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cX += (long int)(((cM+1)*26)/10);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cX += sTime.cYear-i;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cX += (long int)((sTime.cYear-i)/4);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cX += (long int)(((sTime.cYear-i)/100)*6);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cX += (long int)((sTime.cYear-i)/400);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cX %= 7;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sTime.cDayofWeek = (char)cX;&lt;/P&gt;&lt;P&gt;it could be a little more compressed but it work and easy to debug&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 02 May 2010 00:13:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Integer-addition-doesn-t-seem-to-work/m-p/197093#M15821</guid>
      <dc:creator>Juls</dc:creator>
      <dc:date>2010-05-02T00:13:47Z</dc:date>
    </item>
    <item>
      <title>Re: Integer addition doesn t seem to work</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Integer-addition-doesn-t-seem-to-work/m-p/197094#M15822</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not familiar with the algorithm you are using.&amp;nbsp; The earlier code seems to differ somewhat from the later code, so my comments refer to the latter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Firstly, an &lt;FONT face="courier new,courier"&gt;int&lt;/FONT&gt; is a signed 16-bit variable in CW.&amp;nbsp; I can see no particular reason why the code should overflow.&amp;nbsp; The only issue would be if&amp;nbsp; &lt;FONT face="courier new,courier"&gt;sTime.cYear&lt;/FONT&gt; &lt;FONT face="arial,helvetica,sans-serif"&gt;were unsigned and the subtraction of &lt;FONT face="courier new,courier"&gt;i&lt;/FONT&gt; caused a negative result.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With the following expression:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;cX += (long int)(((sTime.cYear-i)/100)*6);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;may be simplified to:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;cX +=&amp;nbsp;(sTime.cYear-i)/100*6;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For integer calculation, this will produce a different result than the following expression:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;cX +=&amp;nbsp;(sTime.cYear-i)*6/100;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;The initial expression will retain the same value for a whole century, and then change by 6.&amp;nbsp; Whereas the modified expression will increment each 16 or 17 years.&amp;nbsp; It all depends on what the algorithm requires.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 02 May 2010 14:06:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Integer-addition-doesn-t-seem-to-work/m-p/197094#M15822</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2010-05-02T14:06:50Z</dc:date>
    </item>
    <item>
      <title>Re: Integer addition doesn t seem to work</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Integer-addition-doesn-t-seem-to-work/m-p/197095#M15823</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I decided to satisfy my curiosity about Zeller's congruence for the day of the week calculation.&amp;nbsp; Actually I cannot see where some of your code fits the formula given within the Wiki reference (calendars.wikia.com/wiki/Zeller's_congruence).&amp;nbsp; This includes the code previously mentioned by me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Firstly, with the months of January and February considered to be the months 13 and 14 of the previous year,&amp;nbsp; and assuming that the parameter i represents the "number of years ago", incrementing this negative parameter to provide the adjustment was, at least, confusing to me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Applying the formula given a little more directly, I might arrive at the following code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;#define cYear&amp;nbsp; sTime.cYear&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;#define cMonth&amp;nbsp;sTime.cMonth&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;#define cDay&amp;nbsp;&amp;nbsp; sTime.cDay&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;#define cDOW&amp;nbsp;&amp;nbsp; sTime.cDayofWeek&lt;BR /&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;int cM, cY, cX, J, K;&lt;BR /&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;if (cMonth &amp;lt;= 2) {&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp; cM = cMonth + 12;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp; cY = cYear - 1;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;else {&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp; cM = cMonth;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp; cY = cYear;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;J = (cY - i)&amp;nbsp;/ 100;&amp;nbsp; // Century&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;K = (cY - i)&amp;nbsp;% 100;&amp;nbsp; // Year of century (0-99)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;cX = (cDay + (cM + 1)*26/10 + K + K/4 + J/4 - 2*J) % 7;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;cDOW = (byte)cX;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// 0 = Saturday -&amp;gt; 6 = Friday&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Mac&lt;/FONT&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 May 2010 01:26:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Integer-addition-doesn-t-seem-to-work/m-p/197095#M15823</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2010-05-03T01:26:35Z</dc:date>
    </item>
    <item>
      <title>Re: Integer addition doesn t seem to work</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Integer-addition-doesn-t-seem-to-work/m-p/197096#M15824</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;(long int)(expression here) There exists no situation where the above typecast is meaningful. The following cases exist for the above: - "Expression" is a small type and will not overflow. Everything is fine. - "Expression" is a small type and will overflow. The overflow has then already occured when the code reaches the typecast. The typecast DOES NOT make the operands in "Expression" 32 bit, only the result.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 May 2010 19:40:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Integer-addition-doesn-t-seem-to-work/m-p/197096#M15824</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2010-05-03T19:40:32Z</dc:date>
    </item>
    <item>
      <title>Re: Integer addition doesn t seem to work</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Integer-addition-doesn-t-seem-to-work/m-p/197097#M15825</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;BigMac:&lt;/P&gt;&lt;P&gt;i is not much of a problem since the lowest value it can get is -1&lt;/P&gt;&lt;P&gt;I use i when we are month jan and feb they are counted as month 13 and 14 of the year before&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;like you said you can use cY to put it in&lt;/P&gt;&lt;P&gt;Im using one of the formula in wiki&lt;/P&gt;&lt;P&gt;the lowest one they are more easy to me since we use the actual year instead of K and J&lt;/P&gt;&lt;P&gt;&lt;A href="http://upload.wikimedia.org/math/d/b/7/db7eff99d21c5d7a2949c5fe68e6b771.png" rel="nofollow" target="_blank"&gt;http://upload.wikimedia.org/math/d/b/7/db7eff99d21c5d7a2949c5fe68e6b771.png&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;each "part" of the formula is set into interger to remove&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your formala seem good (and much compressed)&lt;/P&gt;&lt;P&gt;im just a little incertain about&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;cX = (cDay + (cM + 1)*26/10 + K + K/4 + J/4 - 2*J) % 7;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;Im not sure how cw will do it, will it add each floating poit one after the other if so you might get an error at the end&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-user-name UserName"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="http://forums.freescale.com/../user/viewprofilepage/user-id/2892" rel="nofollow" target="_self"&gt;&lt;SPAN&gt;Lundin&lt;/SPAN&gt;&lt;/A&gt;:&lt;/P&gt;&lt;P&gt;the long int casting remain from when stime.cyear was still a regular int&lt;/P&gt;&lt;P&gt;I can remove them now &lt;IMG alt=":smileyvery-happy:" class="emoticon emoticon-smileyvery-happy" id="smileyvery-happy" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-very-happy.gif" title="Smiley Very Happy" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the original problem was really&lt;/P&gt;&lt;P&gt;with the debugger when I was cheking&lt;/P&gt;&lt;P&gt;cY = (cX + (sTime.cYear-i));&lt;/P&gt;&lt;P&gt;cX = cY + 2;&lt;/P&gt;&lt;P&gt;cY didn t change at all...&lt;/P&gt;&lt;P&gt;both defined as int&lt;/P&gt;&lt;P&gt;but as long int it work so ill leave it like this &lt;IMG alt=":smileyvery-happy:" class="emoticon emoticon-smileyvery-happy" id="smileyvery-happy" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-very-happy.gif" title="Smiley Very Happy" /&gt;&lt;/P&gt;&lt;P&gt;where cX at first was something low like 500... 16-bit is up to 65536 (/2 if signed)&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 May 2010 08:39:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Integer-addition-doesn-t-seem-to-work/m-p/197097#M15825</guid>
      <dc:creator>Juls</dc:creator>
      <dc:date>2010-05-04T08:39:44Z</dc:date>
    </item>
    <item>
      <title>Re: Integer addition doesn t seem to work</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Integer-addition-doesn-t-seem-to-work/m-p/197098#M15826</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For an espression such as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;cX = (cDay + (cM + 1)*26/10 + K + K/4 + J/4 - 2*J) % 7;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;since all variables are integer, the result of any intermediate calculation will also be an integer value (with any remainder simply truncated).&amp;nbsp; Floating point values are only of consideration if one or more of the variables or constants is a floating point type.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 May 2010 13:37:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Integer-addition-doesn-t-seem-to-work/m-p/197098#M15826</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2010-05-04T13:37:47Z</dc:date>
    </item>
  </channel>
</rss>

