<?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>sprintf floating point support NCS</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/93288/sprintf-floating-point-support-ncs</link><description>I cannot seem to get floating point supoort for printf/scranf 
 It works for LOG_INF 
 
 
 
 I have tried the following .conf settings: 
 
 
 CONFIG_NEWLIB_LIBC =y 
 CONFIG_NEWLIB_LIBC_FLOAT_PRINTF =y 
 
 CONFIG_CBPRINTF_FP_SUPPORT =y 
 CONFIG_CBPRINTF_COMPLETE</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 27 Oct 2022 17:47:52 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/93288/sprintf-floating-point-support-ncs" /><item><title>RE: sprintf floating point support NCS</title><link>https://devzone.nordicsemi.com/thread/392908?ContentTypeID=1</link><pubDate>Thu, 27 Oct 2022 17:47:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cab79d5d-4ee2-4008-9166-18280ef3599e</guid><dc:creator>LukeC</dc:creator><description>&lt;p&gt;It must have been some build issue or overlay conflict because it is working now.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sprintf floating point support NCS</title><link>https://devzone.nordicsemi.com/thread/392770?ContentTypeID=1</link><pubDate>Thu, 27 Oct 2022 09:02:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:67ce994a-adb0-4b1f-8fc5-b384604d83ec</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Your printk&amp;nbsp;should be&amp;nbsp;printk(&amp;quot;%s&amp;quot;, str).&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I took hello_world, added these to prj.conf:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_CBPRINTF_COMPLETE=y
CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
CONFIG_CBPRINTF_FP_SUPPORT=y
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Added your functions:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/*
 * Copyright (c) 2012-2014 Wind River Systems, Inc.
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include &amp;lt;zephyr.h&amp;gt;
#include &amp;lt;sys/printk.h&amp;gt;
#include &amp;lt;math.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;

void main(void)
{
	printk(&amp;quot;Hello World! %s\n&amp;quot;, CONFIG_BOARD);
	float f = 0.1234f;
	char str[100];
	sprintf(str,&amp;quot;nopad: %f pad %2.1f\r\n&amp;quot;, f,f );
	printk(&amp;quot;sprintf: %s\n&amp;quot;,str);

	printf(&amp;quot;nopad: %f pad %2.1f\r\n&amp;quot;, f,f);

}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;And here&amp;#39;s the output:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Booting Zephyr OS build v3.1.99-ncs1  ***
Hello World! nrf5340dk_nrf5340_cpuapp
sprintf: nopad: 0.123400 pad 0.1

nopad: 0.123400 pad 0.1
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Which ncs version are you running on? I am currently on ncs v2.1.0&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>