<?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>Casting zero (0) double variable to integer is incorrect</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/55948/casting-zero-0-double-variable-to-integer-is-incorrect</link><description>Hi there, 
 I found very interesting behavior on casting double variables to integer. 
 
 The following code gives me strange result: 
 double dval = 0.; 
 int ival = (int)dval; // &amp;lt; ival = 2 - unexpected result 
 double dval1 = 0.0000001; 
 int ival2</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 13 Jan 2020 08:42:46 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/55948/casting-zero-0-double-variable-to-integer-is-incorrect" /><item><title>RE: Casting zero (0) double variable to integer is incorrect</title><link>https://devzone.nordicsemi.com/thread/228731?ContentTypeID=1</link><pubDate>Mon, 13 Jan 2020 08:42:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:438d56a8-b95d-4df3-8256-f13ab8bbd0cf</guid><dc:creator>AlekseyAK</dc:creator><description>&lt;p&gt;Hi Simon.&lt;/p&gt;
&lt;p&gt;I tested the project with the previous version of the SEGGER Embedded Studio 4.22 and problem is gone.&lt;/p&gt;
&lt;p&gt;I will contact the SEGGER support team with it.&lt;/p&gt;
&lt;p&gt;Thank you very much for your help.&lt;/p&gt;
&lt;p&gt;With best regards, Aleksey.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Casting zero (0) double variable to integer is incorrect</title><link>https://devzone.nordicsemi.com/thread/228444?ContentTypeID=1</link><pubDate>Thu, 09 Jan 2020 23:34:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7396c7df-fa99-421f-9d0e-f371f5fd4c84</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;It seems like the issue is related to Segger Embedded Studio. If you look at&amp;nbsp;your assembly code, you can see that &lt;em&gt;__aeabi_d2iz&lt;/em&gt; is used for casting. In my generated assembly code, __fixdfsi is used. I am using SES 3.40. I tried to upgrade to SES v4.30c and encounter the same issue as you.&lt;/p&gt;
&lt;p&gt;Some solutions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You could downgrade SES&lt;/li&gt;
&lt;li&gt;You could &lt;a href="https://www.segger.com/support/technical-support/"&gt;create a support ticket&lt;/a&gt;&amp;nbsp;on the SES technical support site and ask about this&lt;/li&gt;
&lt;li&gt;I can look into it and try to find a quick fix&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Casting zero (0) double variable to integer is incorrect</title><link>https://devzone.nordicsemi.com/thread/228324?ContentTypeID=1</link><pubDate>Thu, 09 Jan 2020 10:38:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:67d0e66f-ed16-460c-a569-64781e8a9c28</guid><dc:creator>AlekseyAK</dc:creator><description>&lt;p&gt;Hi Simon,&lt;/p&gt;
&lt;p&gt;Yes, compiler type and standard are set as at the picture. The problem reproduces on nRF52832DK board and on our specific device based on nRF52832 MCU.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Aleksey.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Casting zero (0) double variable to integer is incorrect</title><link>https://devzone.nordicsemi.com/thread/227367?ContentTypeID=1</link><pubDate>Fri, 03 Jan 2020 09:50:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a5dc534b-d60b-43a2-ac74-835a5260712e</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I tested your example with an &lt;a href="https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52-DK"&gt;nRF52832 DK&lt;/a&gt;, and it worked fine:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-1d9380b863dc44bbb01c6d1c70e1fb4e/pastedimage1578044909466v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Does your compiler options look like this:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/1280x960/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-1d9380b863dc44bbb01c6d1c70e1fb4e/pastedimage1578044990160v2.png" /&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Casting zero (0) double variable to integer is incorrect</title><link>https://devzone.nordicsemi.com/thread/226914?ContentTypeID=1</link><pubDate>Fri, 27 Dec 2019 10:24:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aec906d5-0752-4282-a6b2-ce60b3413859</guid><dc:creator>AlekseyAK</dc:creator><description>&lt;p&gt;Hi Simon,&lt;/p&gt;
&lt;p&gt;Here the link to the test project, where I am able to reproduce the issue.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://drive.google.com/file/d/1lulj2b3rdxqP_AFQBdMHFg2-38J9euSa/view?usp=sharing"&gt;https://drive.google.com/file/d/1lulj2b3rdxqP_AFQBdMHFg2-38J9euSa/view?usp=sharing&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Also, here is the screenshot of debugging process.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/1024x768/__key/communityserver-discussions-components-files/4/test_5F00_app.png" /&gt;&lt;/p&gt;
&lt;p&gt;Regards, Aleksey.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Casting zero (0) double variable to integer is incorrect</title><link>https://devzone.nordicsemi.com/thread/226898?ContentTypeID=1</link><pubDate>Fri, 27 Dec 2019 09:18:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2ee925a7-f92d-46ae-98b4-8729edb871ba</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I am not able to reproduce your behavior. In both cases, I got &amp;#39;0&amp;#39; as a result in both of the cases. I copied your code into&amp;nbsp;the twi_scanner&amp;nbsp;nRF5 SDK example (logging enabled).&lt;/p&gt;
&lt;p&gt;Could you share your code? I can make the ticket private if you would like to.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>