<?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>float to string in Printf() + ble_nus()</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/41136/float-to-string-in-printf-ble_nus</link><description>Hi 
 I am trying to send the float value to mobile through ble_nus() 
 respective code: 
 
 i tried (&amp;quot;%s%d.02%d&amp;quot;) but i got the result as: 
 
 
 in app</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 03 Dec 2018 18:52:47 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/41136/float-to-string-in-printf-ble_nus" /><item><title>RE: float to string in Printf() + ble_nus()</title><link>https://devzone.nordicsemi.com/thread/160069?ContentTypeID=1</link><pubDate>Mon, 03 Dec 2018 18:52:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1973234b-62cf-4e70-a1c6-42e6aa7656f8</guid><dc:creator>howard n2wx</dc:creator><description>&lt;p&gt;&lt;span class="user-name"&gt; See &lt;a class="internal-link view-user-profile" href="https://devzone.nordicsemi.com/members/joh2"&gt;J&amp;oslash;rgen&lt;/a&gt;&lt;/span&gt;&lt;a class="internal-link view-post navigable" href="https://devzone.nordicsemi.com/f/nordic-q-a/41136/float-to-string-in-printf-ble_nus/159933#159933"&gt;&lt;span class="ui-agodate ui-tip "&gt;&lt;/span&gt;&amp;#39;s&lt;/a&gt; suggestion if you&amp;#39;re on SES, if you&amp;#39;re on IAR right click on your project and select at least the Full scanf formatter&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/78343.Capture.PNG" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: float to string in Printf() + ble_nus()</title><link>https://devzone.nordicsemi.com/thread/159933?ContentTypeID=1</link><pubDate>Mon, 03 Dec 2018 10:40:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f50b3bd-0f6e-4323-bc62-0e977601dffb</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Which compiler/IDE are you using? If using Segger Embedded Studio, you might need to enable Printf floating point support:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-bf87c537df9640fb8a88ffa2ee6488cd/ses_5F00_printf_5F00_float.png" /&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: float to string in Printf() + ble_nus()</title><link>https://devzone.nordicsemi.com/thread/159855?ContentTypeID=1</link><pubDate>Mon, 03 Dec 2018 04:27:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:14fbf9d2-5557-4f8b-9e20-ce519e7d27d0</guid><dc:creator>Sunil vignesh</dc:creator><description>&lt;p&gt;HI howard,&lt;/p&gt;
&lt;p&gt;with reference to this page &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/38703/cannot-print-more-than-two-values-in-a-single-command-line-using-nrf_log_float_marker/149567#149567"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/38703/cannot-print-more-than-two-values-in-a-single-command-line-using-nrf_log_float_marker/149567#149567 &lt;/a&gt;&lt;/p&gt;
&lt;p&gt;i tried &amp;quot;%s%d.%02d&amp;quot; . it shows same. &amp;quot;%d.%02d&amp;quot; result.&lt;/p&gt;
&lt;p&gt;if I use &amp;quot;%f&amp;quot; or &amp;quot;.2f&amp;quot; the result in both serial and mobile app is same&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;AccX = &lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;it shows only the blank space&lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: float to string in Printf() + ble_nus()</title><link>https://devzone.nordicsemi.com/thread/159843?ContentTypeID=1</link><pubDate>Sun, 02 Dec 2018 20:17:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3241d9ab-83ab-4479-827d-adf7f3454f55</guid><dc:creator>howard n2wx</dc:creator><description>&lt;p&gt;Hello Sunil,&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt; float accelX = ((((float)accel.x) / G_TO_LSB) * 9.80655); // in m/s^2
...
      length1 = sprintf(str, &amp;quot;AccX = %d.%02d \n&amp;quot;, accelX);
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Is there a particular reason you&amp;#39;re using two %d in the format strings instead of a single %f or %d?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>