<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/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/"><channel><title>Round of and data precision in Cortex-M4</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/33120/round-of-and-data-precision-in-cortex-m4</link><description> 
Hi, 
I am using STM32F429-Discovery Board (Cortex-M4). When I
define/assign the value to any variable/constant ex. #define X
3.14159265 or float32_t Y=0.30945 etc then it changed to X=3.14159274
or Y= 0.309450001 respectively while these variables/constants</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Round of and data precision in Cortex-M4</title><link>https://community.arm.com/thread/93459?ContentTypeID=1</link><pubDate>Fri, 12 Jun 2015 06:33:53 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:8e800667-0f77-4849-b1e8-27dd75d41fdf</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
The initial courses on numerical programming are quite good to
take, since it&amp;#39;s important to know about the limitations of floating
point numbers, stability of algorithms and how they are affected by
number of valid value digits etc.&lt;/p&gt;

&lt;p&gt;
Double-precision numbers works way better that single-precision
numbers but it doesn&amp;#39;t matter much with a couple of extra valid
digits if used with an algorithm that isn&amp;#39;t stable.&lt;/p&gt;

&lt;p&gt;
In your case - let the compiler compute 1/x instead of first
assigning x to a variable and then compute 1/x. The compiler can
compute the inverse with more value digits than a float can store so
you end up with just a single round-off error instead of first having
one error for assign to x and a second error when the division is
assigned to the new variable.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Round of and data precision in Cortex-M4</title><link>https://community.arm.com/thread/69249?ContentTypeID=1</link><pubDate>Fri, 12 Jun 2015 06:01:13 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:b89436f3-00c8-4728-a73f-4359d86d692b</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
You do realise that not all values can be represented exactly in
binary floating-point format - don&amp;#39;t you?&lt;/p&gt;

&lt;p&gt;
Do you also realise that #define gives a purely textual
expansion?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>