<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>The arithmetic used in lesson6 exercise1 puzzled me.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/111907/the-arithmetic-used-in-lesson6-exercise1-puzzled-me</link><description>In exercise1 lesson6,the step 10 add a picture to show what the number in two registers mean. 
 And in step 11, the temp is calculate by the way as follow: 
 
 But,ad the follow picture,When the temperature is -1℃,the high byte is 0x81 and the low byte</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 17 Jun 2024 12:32:01 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/111907/the-arithmetic-used-in-lesson6-exercise1-puzzled-me" /><item><title>RE: The arithmetic used in lesson6 exercise1 puzzled me.</title><link>https://devzone.nordicsemi.com/thread/489102?ContentTypeID=1</link><pubDate>Mon, 17 Jun 2024 12:32:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5bffdd37-2c3a-4eb9-bf4b-63504f885b44</guid><dc:creator>Naeem Maroof</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;The reason is that the two bytes that you have referred to have 2&amp;#39;s complement representation:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1718627485317v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;So, the two&amp;#39;s complement of -1 is 0xFF, and if you store this byte instead of 0x81, you would get -1C.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: The arithmetic used in lesson6 exercise1 puzzled me.</title><link>https://devzone.nordicsemi.com/thread/488200?ContentTypeID=1</link><pubDate>Tue, 11 Jun 2024 00:14:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eeef6c47-f50e-4b7f-80d1-41cdd9837862</guid><dc:creator>Chaoyue Ying</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;After the if-condition,it will calculate the cTemp.&lt;/p&gt;
&lt;p&gt;According to the formula,the result of cTemp is -127.Based on the previous assumptions,the result&amp;nbsp; of cTemp should equal to -1.It puzzled me.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: The arithmetic used in lesson6 exercise1 puzzled me.</title><link>https://devzone.nordicsemi.com/thread/487914?ContentTypeID=1</link><pubDate>Fri, 07 Jun 2024 12:43:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:be37d3a6-5ff6-4510-b1e1-3f4e11431079</guid><dc:creator>Naeem Maroof</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The code could have been written in different ways to implement as per the datasheet.&lt;/p&gt;
&lt;p&gt;However,&amp;nbsp;the calculations performed here gives correct result.&lt;/p&gt;
&lt;p&gt;As you have said that [0x00 , 0x81] should give -2032;&lt;/p&gt;
&lt;p&gt;Yes, it is giving -2032&lt;/p&gt;
&lt;p&gt;in the first line of code temp becomes 2064&lt;/p&gt;
&lt;p&gt;and then the if-condition corrects the result and temp becomes -2032&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>