<?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>Using floats with sprintf, gcc-arm-none-eabi, nRF51822</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/28999/using-floats-with-sprintf-gcc-arm-none-eabi-nrf51822</link><description>I want to use some floating point variables in my code and format a string with them in. These are latitude and longitude values from a GPS which I&amp;#39;m then sending to a GSM modem. I&amp;#39;m using the gcc-arm-none-eabi toolchain with the unofficial &amp;quot;pure-gcc</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 01 Aug 2023 10:43:44 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/28999/using-floats-with-sprintf-gcc-arm-none-eabi-nrf51822" /><item><title>RE: Using floats with sprintf, gcc-arm-none-eabi, nRF51822</title><link>https://devzone.nordicsemi.com/thread/439221?ContentTypeID=1</link><pubDate>Tue, 01 Aug 2023 10:43:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:03fdc1fc-8407-4e33-82b2-ee9b42e4ee17</guid><dc:creator>RVA</dc:creator><description>&lt;p&gt;Works also in nrf52840 with&amp;nbsp;gcc-arm-none-eabi-6-2017-q2-update&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using floats with sprintf, gcc-arm-none-eabi, nRF51822</title><link>https://devzone.nordicsemi.com/thread/411482?ContentTypeID=1</link><pubDate>Wed, 22 Feb 2023 19:18:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ddf043f5-d29d-4c9f-a114-3b6ddcfecdc5</guid><dc:creator>lvh831</dc:creator><description>&lt;p&gt;Thank you Eliot. You&amp;#39;re a kind person!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using floats with sprintf, gcc-arm-none-eabi, nRF51822</title><link>https://devzone.nordicsemi.com/thread/114673?ContentTypeID=1</link><pubDate>Wed, 24 Jan 2018 13:45:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:49ebe374-28ff-4f58-bb2b-e5ca8a7e8dca</guid><dc:creator>Aboisleux</dc:creator><description>&lt;p&gt;thank you so much!!! I was stuck, and this was driving me crazy. I could do sprintf for integers&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using floats with sprintf, gcc-arm-none-eabi, nRF51822</title><link>https://devzone.nordicsemi.com/thread/114672?ContentTypeID=1</link><pubDate>Fri, 23 Oct 2015 11:44:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fd723ae3-081e-4439-aef1-7a6bd5993d36</guid><dc:creator>Luis</dc:creator><description>&lt;p&gt;you saved me so much time. Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using floats with sprintf, gcc-arm-none-eabi, nRF51822</title><link>https://devzone.nordicsemi.com/thread/114671?ContentTypeID=1</link><pubDate>Mon, 05 Oct 2015 06:18:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:037b0efc-35c0-4a1b-964b-323a395d1b7c</guid><dc:creator>Mahesh Venkitachalam</dc:creator><description>&lt;p&gt;great find!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using floats with sprintf, gcc-arm-none-eabi, nRF51822</title><link>https://devzone.nordicsemi.com/thread/114676?ContentTypeID=1</link><pubDate>Tue, 27 Jan 2015 21:21:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f728751-907f-44e0-8dd3-a8c7173afc1f</guid><dc:creator>Eliot Stock</dc:creator><description>&lt;p&gt;Fine for my use case but useful to know, thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using floats with sprintf, gcc-arm-none-eabi, nRF51822</title><link>https://devzone.nordicsemi.com/thread/114675?ContentTypeID=1</link><pubDate>Tue, 27 Jan 2015 21:16:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c27a3ea-af41-4595-a286-d8347772f58e</guid><dc:creator>Charles Manning</dc:creator><description>&lt;p&gt;Just a side comment to what you&amp;#39;re trying to do...&lt;/p&gt;
&lt;p&gt;Floats only give about 7 digits of precision. That will give you a worst case precision of about 2 metres .&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using floats with sprintf, gcc-arm-none-eabi, nRF51822</title><link>https://devzone.nordicsemi.com/thread/114677?ContentTypeID=1</link><pubDate>Tue, 27 Jan 2015 12:58:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fd14af8b-9411-4d66-b7a0-fc665a604fe7</guid><dc:creator>Pher</dc:creator><description>&lt;p&gt;Hi Elliot, do you now if it is possible to do the same thing on KEIL MDK?? By now, i cant use printf functions with floats inside! Every time i try to use it, in the firsts prints i have always the result of 0.000000 and the program crashes a little bit after with an hard fault handler!&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using floats with sprintf, gcc-arm-none-eabi, nRF51822</title><link>https://devzone.nordicsemi.com/thread/114674?ContentTypeID=1</link><pubDate>Mon, 17 Feb 2014 15:06:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:26cee580-078c-4f0a-9555-75a8706ccf8e</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;Strange. I don&amp;#39;t have that flag. Well, its fine in any way as long as it works.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using floats with sprintf, gcc-arm-none-eabi, nRF51822</title><link>https://devzone.nordicsemi.com/thread/114670?ContentTypeID=1</link><pubDate>Mon, 17 Feb 2014 14:54:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0eb22ca5-371d-4e82-a772-4467d2113c3b</guid><dc:creator>Eliot Stock</dc:creator><description>&lt;p&gt;The trick seems to be to add this linker flag to your Makefile:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;LDFLAGS += -u _printf_float&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Looks like &amp;quot;printf&amp;quot; here also applies to sprintf.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using floats with sprintf, gcc-arm-none-eabi, nRF51822</title><link>https://devzone.nordicsemi.com/thread/114669?ContentTypeID=1</link><pubDate>Mon, 17 Feb 2014 14:52:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a0a2c82e-98bb-4fea-9cf1-0d0786d0ba7b</guid><dc:creator>Eliot Stock</dc:creator><description>&lt;p&gt;Thanks! There was in fact a linker flag in the Makefile in that project which did the trick. Posting it below.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using floats with sprintf, gcc-arm-none-eabi, nRF51822</title><link>https://devzone.nordicsemi.com/thread/114668?ContentTypeID=1</link><pubDate>Mon, 17 Feb 2014 14:14:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8ca6da6c-ea92-4fd7-a764-415f6ac01978</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;Hi Eliot,
Printing floats is working for me with GNU GCC 4.8.3 in nrf51822. I am using printf as shown by a kind person &lt;a href="https://github.com/hlnd/printf-gcc"&gt;here&lt;/a&gt;.
For example&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
    int i = 7;
    float ab = 1.2;
    printf(&amp;quot;A printf test: %.3f %d\n&amp;quot;, ab, i);

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;gives an output of&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;A printf test: 1.200 7&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Try this. As far as I know, I don&amp;#39;t see anything special related to floats in my makefile.
PS. Cool start-up. All the best!
Prithvi&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>