<?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>How to print float values using SEGGER RTT</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/19302/how-to-print-float-values-using-segger-rtt</link><description>Hi,
My question is similar to this devzone.nordicsemi.com/.../ but I can&amp;#39;t get it to work. 
 I am using SEGGER_RTT_WriteString and sprintf for debugging, but I am not able to print a float value such as 3.1415. I use the folowing code for printing intergers</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 28 Apr 2017 09:30:47 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/19302/how-to-print-float-values-using-segger-rtt" /><item><title>RE: How to print float values using SEGGER RTT</title><link>https://devzone.nordicsemi.com/thread/74819?ContentTypeID=1</link><pubDate>Fri, 28 Apr 2017 09:30:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de1fd8ae-39b8-4bb8-b14b-993863b8c58d</guid><dc:creator>Sunil Shenoy</dc:creator><description>&lt;p&gt;@Roger Clark : This method might not yield the right answer if a 0 succeeds the decimal point.
Eg: If the number is 3.014, it would print 3.14 while ignoring the 0 after the decimal point.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to print float values using SEGGER RTT</title><link>https://devzone.nordicsemi.com/thread/74818?ContentTypeID=1</link><pubDate>Mon, 30 Jan 2017 01:42:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0c6acf2c-1647-4d5c-b33c-c4477f6c6620</guid><dc:creator>Roger Clark</dc:creator><description>&lt;p&gt;If you numbers are in the range that fits in an int (32 bit signed) i.e less than a few billion, then you can just write some simple code to split the number at the decimal point, and print the digits to the left of the point as an integer, then print a &amp;quot;.&amp;quot; then print the digits to the right of the point.&lt;/p&gt;
&lt;p&gt;e.g.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define PRECISION 10000
int intPart = (int) floatNumber;
int decimalPart = (floatNumber - intPart) * PRECISION;

prinf(&amp;quot;%d.%d&amp;quot;,intPart,decimalPart);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This would give you an answer to 4 decimal places&lt;/p&gt;
&lt;p&gt;If however your number is something like 1.2345 E-9 then its you will need to pull in a library to handle that sort of complex display&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to print float values using SEGGER RTT</title><link>https://devzone.nordicsemi.com/thread/74817?ContentTypeID=1</link><pubDate>Sun, 29 Jan 2017 14:26:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a7d6b437-793a-475d-92ce-186a6a15d927</guid><dc:creator>Jan Lundskov</dc:creator><description>&lt;p&gt;I am using the stdio library. When I look in the stdio.h file I can find the following description:&lt;/p&gt;
&lt;p&gt;&amp;quot;Some library variants do not support the \q{f} and \q{F} conversion specifiers in order to reduce code
and data space requirements; please ensure that you have selected the correct library in
the \b{Printf Floating Point Support} property of the project if you use these conversion specifiers.&amp;quot;&lt;/p&gt;
&lt;p&gt;It is not described specifcally under the fprintf or printf declaration though.&lt;/p&gt;
&lt;p&gt;If I go to the Project Options under Printf/Scanf under the Linker section, then there is an option to set &amp;#39;Printf Floating Point Supported&amp;#39; to either Yes or No. It is by default set to No.&lt;/p&gt;
&lt;p&gt;After setting this option to Yes it works:-)&lt;/p&gt;
&lt;p&gt;Thank you so much for your help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to print float values using SEGGER RTT</title><link>https://devzone.nordicsemi.com/thread/74816?ContentTypeID=1</link><pubDate>Sun, 29 Jan 2017 10:46:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:728fb15e-1684-4f47-9d54-aec6aacdef11</guid><dc:creator>butch</dc:creator><description>&lt;p&gt;What C library (implementing sprintf()) are you using?  You might explore whether the library supports sprintf for float arguments, as in this old thread: &lt;a href="http://www.cypress.com/forum/psoc-creator-software/sprintf-bug-psoc-creator-3-5lp-and-format-f"&gt;www.cypress.com/.../sprintf-bug-psoc-creator-3-5lp-and-format-f&lt;/a&gt;.  In other words, conversion from float to string by sprintf() might not be implemented in the library, and have a weak definition that does nothing i.e yields an empty string.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>