<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>LeafLabs Garden &#187; User Favorites: ratho</title>
		<link><a href='http://forums.leaflabs.com/profile.php?id=3746'>3746</a></link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:11:28 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://forums.leaflabs.com/search.php</link>
		</textInput>
		<atom:link href="http://forums.leaflabs.com/rss.php?profile=3746" rel="self" type="application/rss+xml" />

		<item>
			<title>menecken on "Libmaple + Windows"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2618#post-104802</link>
			<pubDate>Mon, 21 Oct 2013 03:32:37 +0000</pubDate>
			<dc:creator>menecken</dc:creator>
			<guid isPermaLink="false">104802@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Any progress on this one? &#60;/p&#62;
&#60;p&#62;Still getting the MS-DOS style warnings as well as a &#34;build\\.\\libmaple: No such file or directory&#34; error...&#60;/p&#62;
&#60;p&#62;Thanks in advance&#60;/p&#62;
&#60;p&#62;Ben
&#60;/p&#62;</description>
		</item>
		<item>
			<title>lostinspacebar on "Libmaple + Windows"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2618#post-13201</link>
			<pubDate>Wed, 05 Sep 2012 20:11:15 +0000</pubDate>
			<dc:creator>lostinspacebar</dc:creator>
			<guid isPermaLink="false">13201@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I've put my changes here: &#60;a href=&#34;https://github.com/lostinspacebar/libmaple/tree/windows_build&#34; rel=&#34;nofollow&#34;&#62;https://github.com/lostinspacebar/libmaple/tree/windows_build&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;What's there DOES NOT compile correctly obviously. The thing comes to a halt at libmaple/rules.mk. That's the first place make encounters paths in the target definitions that have colons in them. &#60;/p&#62;
&#60;p&#62;Would love to work together to get this stuff working on Windows. Do you have any ideas so far?&#60;/p&#62;
&#60;p&#62;P.S. I dunno if my first post sounded hostile. It wasn't meant to. Partially just pissed off at make for doing stupid shit and windows for having colons in its paths.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mbolivar on "Libmaple + Windows"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2618#post-13003</link>
			<pubDate>Thu, 30 Aug 2012 14:44:30 +0000</pubDate>
			<dc:creator>mbolivar</dc:creator>
			<guid isPermaLink="false">13003@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;This is a problem that we have to solve as well. The Wiring people are also having issues with Make on Windows; it's a show-stopper for the next IDE release, so it's going to be getting lots of attention.&#60;/p&#62;
&#60;p&#62;I'm going to try to keep a single, make-based build system to avoid that redundancy. Can you share your patches so we can work together?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>lostinspacebar on "Libmaple + Windows"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2618#post-12984</link>
			<pubDate>Wed, 29 Aug 2012 11:04:02 +0000</pubDate>
			<dc:creator>lostinspacebar</dc:creator>
			<guid isPermaLink="false">12984@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi,&#60;/p&#62;
&#60;p&#62;I've started some work on making libmaple compile on windows with codesourcery (or similar GNU tools on windows). I'm getting close, but the only problem right now is that GNU make doesn't support colons (':') in path names for targets. Escaping them doesn't seem to make a difference (still gives me a &#34;multiple targets&#34; error).&#60;/p&#62;
&#60;p&#62;This is kind of a show stopper for me right now. I was wondering what everyone thought about me doing something specific for windows. Like making makefiles for nmake instead of GNU make. I can take the responsibility of keeping them up to date with changes to libmaple. I know there is some redundancy there but the current state of windows buildage of libmaple is annoying at best.&#60;/p&#62;
&#60;p&#62;- Aditya
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Serial1.print decimal places"</title>
			<link>http://forums.leaflabs.com/topic.php?id=844&amp;page=2#post-5798</link>
			<pubDate>Fri, 29 Jul 2011 14:19:30 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">5798@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;robodude666&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;By omitting the f, you are stating to the compiler that this number is a double.&#60;/p&#62;
&#60;/blockquote&#62;
&#60;p&#62;Agreed.&#60;br /&#62;
But it may be &#34;worse than that Jim&#34; :-)&#60;/p&#62;
&#60;p&#62;It was true for several versions of C, starting at K&#38;amp;R, that mixed arithmetic had to be carried out in &#60;code&#62;double&#60;/code&#62;. So it can get quite costly (in CPU time).&#60;br /&#62;
(I just tried to check, but the ISO standards are not public! Why do we accept standards that are not published for free?)&#60;/p&#62;
&#60;p&#62;I looked at the compiler documentation, but it refers to the standards :-(
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Serial1.print decimal places"</title>
			<link>http://forums.leaflabs.com/topic.php?id=844&amp;page=2#post-5797</link>
			<pubDate>Fri, 29 Jul 2011 13:44:47 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">5797@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;samtal -&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;(although my opinion is that the compiler should have understood that division of any two numbers is by default float)&#60;/p&#62;
&#60;/blockquote&#62;
&#60;p&#62;It often trips people up at first.&#60;/p&#62;
&#60;p&#62;C and C++ have &#60;strong&#62;always&#60;/strong&#62; used '/' to mean integer division when both operands are integers.&#60;br /&#62;
This is enshrined in all versions of the language from the original K&#38;amp;R definition through to modern ISO standards, so it isn't something recent :-)&#60;/p&#62;
&#60;p&#62;It has several benefits:&#60;br /&#62;
1. operations on integers always yield an integer result. IMHO, this is a very easy rule to remember.&#60;br /&#62;
2. Integer division is a 'cheaper' operation than floating point division (especially on a microcontroller where these concerns matter more), so the lowest-cost operation is the default&#60;br /&#62;
3. It is easy to get floating point divide, for example &#60;code&#62;float number = 1234.0f / 53.0f;&#60;/code&#62;, or &#60;code&#62;float number = 1234 / 53.0f;&#60;/code&#62;, &#60;code&#62;float number = 1234/(float)53;&#60;/code&#62;, &#60;code&#62;float x  = 1234; number = x/53;&#60;/code&#62; which all have the benefit of being more explicit and with less ambiguity.&#60;br /&#62;
4. There is no requirement for an extra 'integer divide' operator. Some languages have both a floating point divide and an integer divide operator (let's call integer divide 'div'). That can then get a bit weird if the programmer writes &#60;code&#62;1234 div 53.4&#60;/code&#62;. In this sort of case, I think it is clearer, because it is more explicit, to write something like &#60;code&#62;1234 / trunc(53.5)&#60;/code&#62; or &#60;code&#62;trunc(1234 / 53.5)&#60;/code&#62; (or the other options using &#60;code&#62;round()&#60;/code&#62;)&#60;br /&#62;
5. Floating point operations are inexact, for example, &#60;code&#62;int i = (int)(1.0/3.0+1.0/3.0+1.0/3.0);&#60;/code&#62; does not give 1, but integer operations are exact (noting that overflow stops that being true), so a default which is exact has significant advantages. &#60;/p&#62;
&#60;p&#62;What operator would you use to show integer division if '/' means floating point division?&#60;br /&#62;
The operator would need to be non-alphanumeric characters, preferably in the ASCII range, to keep the language parser 'consistent' (i.e. not have to use even more powerful grammar mechanisms).&#60;/p&#62;
&#60;p&#62;Edit: Division, like all float and double operations, should be carried out with &#60;code&#62;double&#60;/code&#62; precision if either operand is a float or double and the other integer. I believe it can be carried out in &#60;code&#62;float&#60;/code&#62; if both operands are &#60;code&#62;float&#60;/code&#62; (I think that was a C90/C99-ism, but might have been a GNU extension.)&#60;/p&#62;
&#60;p&#62;HTH
&#60;/p&#62;</description>
		</item>
		<item>
			<title>robodude666 on "Serial1.print decimal places"</title>
			<link>http://forums.leaflabs.com/topic.php?id=844&amp;page=2#post-5794</link>
			<pubDate>Fri, 29 Jul 2011 13:08:41 +0000</pubDate>
			<dc:creator>robodude666</dc:creator>
			<guid isPermaLink="false">5794@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Not completely correct.&#60;/p&#62;
&#60;p&#62;By omitting the &#60;code&#62;f&#60;/code&#62;, you are stating to the compiler that this number is a double. If you're storing a double in a float variable, a conversion may take place reducing overall performance. By including the &#60;code&#62;f&#60;/code&#62;, you are stating this is a float making the compiler's job easier. While it's not needed, it's good to have. If you're casting from an int to a float, a &#60;code&#62;(float)&#60;/code&#62; works too:&#60;/p&#62;
&#60;p&#62;&#60;code&#62;float number = (float)1234/(float)53;&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;-robodude666
&#60;/p&#62;</description>
		</item>
		<item>
			<title>samtal on "Serial1.print decimal places"</title>
			<link>http://forums.leaflabs.com/topic.php?id=844&amp;page=2#post-5793</link>
			<pubDate>Fri, 29 Jul 2011 12:51:47 +0000</pubDate>
			<dc:creator>samtal</dc:creator>
			<guid isPermaLink="false">5793@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Indeed it works that way! (although my opinion is that the compiler should have understood that division of any two numbers is by default float)&#60;br /&#62;
I also noticed that one does not need both the decimal and the 'f'. Either is sufficient.&#60;br /&#62;
Here is how I read dual adc and break it down to volts: (I know there are other ways as well...)&#60;br /&#62;
void loop()&#60;br /&#62;
{&#60;/p&#62;
&#60;p&#62;int read_result = ADC1_BASE-&#38;gt;DR;&#60;/p&#62;
&#60;p&#62;int adc1_data = (read_result &#38;amp; 4095);&#60;br /&#62;
int adc2_data = (read_result &#38;gt;&#38;gt;16 &#38;amp; 4095);&#60;/p&#62;
&#60;p&#62;SerialUSB.print(&#34;ADC1_data: &#34;);&#60;br /&#62;
SerialUSB.print((float)adc1_data / 4095 *3.3,3);&#60;br /&#62;
SerialUSB.print(&#34;  ADC2_data: &#34;);&#60;br /&#62;
SerialUSB.println((float)adc2_data / 4095 *3.3,3);&#60;br /&#62;
SerialUSB.println();&#60;br /&#62;
  delay (1000);&#60;br /&#62;
}
&#60;/p&#62;</description>
		</item>
		<item>
			<title>robodude666 on "Serial1.print decimal places"</title>
			<link>http://forums.leaflabs.com/topic.php?id=844&amp;page=2#post-5789</link>
			<pubDate>Fri, 29 Jul 2011 09:18:54 +0000</pubDate>
			<dc:creator>robodude666</dc:creator>
			<guid isPermaLink="false">5789@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;As far as the compiler knows, you're dividing two ints and then casting that to a float. You must show that you're using floats:&#60;/p&#62;
&#60;p&#62;&#60;code&#62;float number = 1234.0f / 53.0f;&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;You will end up with the following results:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;23.283
23.2830181122
23.28
23.28&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;just as the println statements suggest they should be. No reason to abandon your Maple =]. It's a brilliant little board.&#60;/p&#62;
&#60;p&#62;-robodude666
&#60;/p&#62;</description>
		</item>
		<item>
			<title>samtal on "Serial1.print decimal places"</title>
			<link>http://forums.leaflabs.com/topic.php?id=844&amp;page=2#post-5788</link>
			<pubDate>Fri, 29 Jul 2011 08:11:46 +0000</pubDate>
			<dc:creator>samtal</dc:creator>
			<guid isPermaLink="false">5788@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi,&#60;br /&#62;
After wasting half day trying to print a simple result such as 1234/53=23.283 I keep getting 23.00.&#60;br /&#62;
I have tried everything I know from any possible programming language print formatting (Basic, C, C++, Fortran, Java, C#.....) and only got errors.&#60;br /&#62;
Eventually, I searched the form and found out that the Maple does not have that VERY BASIC capability of simple decimal fraction number printing......&#60;br /&#62;
Well, I found out that there are new print.cpp and print.h from June 8, 2011 that are supposed to make it Arduino compatible (Arduino has all kinds of formatting) which I copied (NO download?) and replaced my older files, but for no avail.&#60;br /&#62;
Now I can get 23.0000000 which is 'better precision', but still worthless.&#60;br /&#62;
Is there a real solution or do I have to abndon my 2 new Maple boards?&#60;br /&#62;
I need math functions with readable results!!&#60;/p&#62;
&#60;p&#62;#include &#38;lt;stdlib.h&#38;gt;&#60;/p&#62;
&#60;p&#62;void setup()&#60;br /&#62;
{&#60;br /&#62;
}&#60;br /&#62;
void loop()&#60;br /&#62;
{&#60;br /&#62;
  char buf[10];&#60;br /&#62;
  float number = 1234/53;  //=23.28301886792452830188679245283&#60;/p&#62;
&#60;p&#62;  SerialUSB.println(gcvt(number,5,buf));   //=23&#60;br /&#62;
  SerialUSB.println( number,DEC);  //=23.0000000000&#60;br /&#62;
  SerialUSB.println(number,2); //=23.00&#60;br /&#62;
  SerialUSB.println((float)number,2); //=23.00&#60;/p&#62;
&#60;p&#62;  delay(1000);&#60;br /&#62;
}&#60;br /&#62;
samtal
&#60;/p&#62;</description>
		</item>
		<item>
			<title>ratho on "Serial1.print decimal places"</title>
			<link>http://forums.leaflabs.com/topic.php?id=844&amp;page=2#post-5101</link>
			<pubDate>Thu, 09 Jun 2011 12:01:56 +0000</pubDate>
			<dc:creator>ratho</dc:creator>
			<guid isPermaLink="false">5101@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Thank you! This works as desired :)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>snigelen on "Serial1.print decimal places"</title>
			<link>http://forums.leaflabs.com/topic.php?id=844&amp;page=2#post-5080</link>
			<pubDate>Thu, 09 Jun 2011 02:33:34 +0000</pubDate>
			<dc:creator>snigelen</dc:creator>
			<guid isPermaLink="false">5080@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Well the 5 means you want 5 decimals ;-)&#60;/p&#62;
&#60;p&#62;You can use, for example, gcvt, which is a little smaller than sprintf. Like&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;#include &#38;lt;stdlib.h&#38;gt;

void setup()
{
}

void loop()
{
  float x = 3.1415;
  float y = 0.0021;
  float z = 1.234e6;

  char buf[20];

  if (SerialUSB.available()) {
    SerialUSB.read();

    SerialUSB.println(gcvt(x,5,buf));
    SerialUSB.println(gcvt(y,5,buf));
    SerialUSB.println(gcvt(z,5,buf));
  }
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;From the man-page (in linux):&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;DESCRIPTION
       The gcvt() function converts number to a minimal length null-terminated
       ASCII string and stores the result in buf.  It produces ndigit signifi‐
       cant digits in either printf(3) F format or E format.&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>ratho on "Serial1.print decimal places"</title>
			<link>http://forums.leaflabs.com/topic.php?id=844&amp;page=2#post-5064</link>
			<pubDate>Wed, 08 Jun 2011 15:59:25 +0000</pubDate>
			<dc:creator>ratho</dc:creator>
			<guid isPermaLink="false">5064@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi,&#60;br /&#62;
thank you! Now it works :)&#60;br /&#62;
Is there a posibility to cut the 0?&#60;br /&#62;
If I use print(0.002, 5) I get 0.00200 -&#38;gt; always 5 positions after the decimal point.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mbolivar on "Serial1.print decimal places"</title>
			<link>http://forums.leaflabs.com/topic.php?id=844&amp;page=2#post-5062</link>
			<pubDate>Wed, 08 Jun 2011 15:42:31 +0000</pubDate>
			<dc:creator>mbolivar</dc:creator>
			<guid isPermaLink="false">5062@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;ratho,&#60;/p&#62;
&#60;p&#62;Thanks for the heads-up.  Our Print implementation is adapted from an earlier version of Arduino's, which didn't specify a way to print out more than 2 decimal digits.  I have updated our Print implementation to better track changes made to the Arduino version:&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;https://github.com/leaflabs/libmaple/commit/5c847fda31d956cc62c511a5fe277d197777de39&#34; rel=&#34;nofollow&#34;&#62;https://github.com/leaflabs/libmaple/commit/5c847fda31d956cc62c511a5fe277d197777de39&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;You can now give an optional number of digits argument when printing floating-point values.&#60;/p&#62;
&#60;p&#62;If you're using the IDE, you'll have to make the changes in that commit yourself or wait for the next version to come out.  If you're using the Unix toolchain, just pull the latest libmaple and let us know how it goes.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>snigelen on "Serial1.print decimal places"</title>
			<link>http://forums.leaflabs.com/topic.php?id=844&amp;page=2#post-5061</link>
			<pubDate>Wed, 08 Jun 2011 15:03:12 +0000</pubDate>
			<dc:creator>snigelen</dc:creator>
			<guid isPermaLink="false">5061@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Yes, you're right. On Arduino it works that way, but I forgot the Maple isn't compatible in that point (I discovered the same thing about six months ago but forgot).&#60;/p&#62;
&#60;p&#62;But there's sprintf and probably others from newlib you can use. But they will eat a lot of flash :-(
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
