<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[RemoteXY community — Convert a float to a string]]></title>
	<link rel="self" href="https://forum.remotexy.com/extern.php?action=feed&amp;tid=957&amp;type=atom" />
	<updated>2020-10-23T18:14:20Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.remotexy.com/viewtopic.php?id=957</id>
		<entry>
			<title type="html"><![CDATA[Re: Convert a float to a string]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=3434#p3434" />
			<content type="html"><![CDATA[<p>Hi Robin</p><p>I have been dealing with &quot;Read buffer overflow&quot;. No real idea, where it is sudenly coming from. </p><p>Can&#039;t you post an exemple please?</p><p>Up to now my past versions were running well and I cannot understand what I did wrong to make RemoteXY unhappy adding a new page where all looks really fine.</p><p>Thanks.</p><p>Kissinno</p>]]></content>
			<author>
				<name><![CDATA[KissInno]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=951</uri>
			</author>
			<updated>2020-10-23T18:14:20Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=3434#p3434</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Convert a float to a string]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=2771#p2771" />
			<content type="html"><![CDATA[<p>Guillaume,</p><p><strong>THANK YOU</strong>. Sorry for shouting, but I am happy.</p><p>I had a problem with the design in the editor. Now that I have sorted that out, it works.</p><p>Thank you also for the warning about buffer overflow as -127.0 is measured if the probe becomes disconnected. I have trapped this and change the string to &quot;ERROR&quot;</p><p>Robin<br /><img src="https://forum.remotexy.com/img/smilies/big_smile.png" width="15" height="15" alt="big_smile" /></p>]]></content>
			<author>
				<name><![CDATA[Robin]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=1298</uri>
			</author>
			<updated>2020-04-01T07:46:02Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=2771#p2771</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Convert a float to a string]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=2764#p2764" />
			<content type="html"><![CDATA[<p>Welcome,</p><p>You can use function dtostrf to convert float to string, then function strcat to add the &quot;°C&quot; behind, or you can simply use function sprintf:</p><div class="codebox"><pre><code>float val = 12.3456789;
char str[8]; // buffer to hold string &quot;-XX.X°C\0&quot;

dtostrf( val, 5, 1, str );
strcat( str, &quot;°C&quot; );

// or

sprintf( str, &quot;%.1f°C&quot;, val );</code></pre></div><p>The downside of sprintf is, it uses a lot (1 to 2kB IIRC) of program space.</p><p>And to avoid buffer overflow if temperature sensor gives an incorrect reading like 12345°C (IDK if it&#039;s even possible),&nbsp; you must check if the temperature is in a range that can fit inside the buffer (so -99 to 999, less than 4 characters in front of the dot), or increase buffer size.</p>]]></content>
			<author>
				<name><![CDATA[Guillaume]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=23</uri>
			</author>
			<updated>2020-03-31T15:29:06Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=2764#p2764</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Convert a float to a string]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=2763#p2763" />
			<content type="html"><![CDATA[<p>Sorry if this is simple, I am a real beginner here.</p><p>I am using an Arduino. I have a float T (a temperature from a DS18B20).</p><p>I want to display it in the form <strong>XX.X°C</strong>.</p><p>I am missing something simple, but I don&#039;t have much hair to pull out, please help me save what little I have left.</p><p>Thank you.</p>]]></content>
			<author>
				<name><![CDATA[Robin]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=1298</uri>
			</author>
			<updated>2020-03-31T15:04:13Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=2763#p2763</id>
		</entry>
</feed>
