<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>the scootabug virus &#187; double</title>
	<atom:link href="http://www.getbugged.com/tag/double/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.getbugged.com</link>
	<description>Just another WordPress site</description>
	<lastBuildDate>Fri, 06 Jan 2012 06:47:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>How to Serial.print a Double on an Arduino</title>
		<link>http://www.getbugged.com/2008/11/22/how-to-serialprint-a-double-on-an-arduino/</link>
		<comments>http://www.getbugged.com/2008/11/22/how-to-serialprint-a-double-on-an-arduino/#comments</comments>
		<pubDate>Sat, 22 Nov 2008 07:54:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Code Library]]></category>
		<category><![CDATA[double]]></category>
		<category><![CDATA[float]]></category>
		<category><![CDATA[serial.print]]></category>
		<category><![CDATA[serial.println]]></category>

		<guid isPermaLink="false">http://getbugged.com/?p=3</guid>
		<description><![CDATA[I found the following code on the Arduino forums and decided to post it here for future reference. It allows you to print a double/float to the serial port.  You&#8217;ll need to edit the last line if you didn&#8217;t want a carriage return after the value is printed.  It works a treat. void printDouble(double val, [...]]]></description>
			<content:encoded><![CDATA[<p>I found the following code on the Arduino forums and decided to post it here for future reference.</p>
<p>It allows you to print a double/float to the serial port.  You&#8217;ll need to edit the last line if you didn&#8217;t want a carriage return after the value is printed.  It works a treat.</p>
<pre class="brush: cpp;">
void printDouble(double val, byte precision){
// prints val with number of decimal places determine by precision
// precision is a number from 0 to 6 indicating the desired decimial places
// example: printDouble( 3.1415, 2); // prints 3.14 (two decimal places)

Serial.print (int(val));  //prints the int part
if( precision &gt; 0) {
Serial.print(&quot;.&quot;); // print the decimal point
unsigned long frac;
unsigned long mult = 1;
byte padding = precision -1;
while(precision--)
mult *=10;

if(val &gt;= 0)
frac = (val - int(val)) * mult;
else
frac = (int(val)- val ) * mult;
unsigned long frac1 = frac;
while( frac1 /= 10 )
padding--;
while(padding--)
Serial.print(&quot;0&quot;);
Serial.println(frac,DEC) ;
}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.getbugged.com/2008/11/22/how-to-serialprint-a-double-on-an-arduino/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

