Been tinkering with this for a while and just about scratching my head at why it's been so difficult.

I am using the Adafruit library to pull sensor data from 2 DHT11's the values returned are float varshttps://github.com/adafruit/DHT-sensor-library

I'm then trying to post them to a remote server using an Ethernet shield with a ENC28J60 chipusing the EtherCard libraryhttps://github.com/jcw/ethercard

did some homework and tinkered with this on and off for a couple weeks, most of the common C methods aren't available and I've yet to find a workable reference

I have a sample of my code as it stands posted athttps://gist.github.com/4700415

line 132 makes the GET call (commented out)lines 121 and after are attempts to concatenate the values, I know this is an easy fix for someone with experience so I'm reaching out for a snippet or reference

I had some trouble with floats and strings but I got it working. Nick Gammon pointed out that there are some issues with the current string library, it may not be your immediate issue but its worth noteing .check this out maybe it will help. http://arduino.cc/forum/index.php/topic,146586.0.html

if you look in my code I put a few floats into Strings just after the loop()

Multiply it by 10^n where n is the number of digits after the decimal point.Assign the resulting value to an int or long depending on the size of n.Do something like this to actually stuff it into the string:

Arrch certainly pointed me in the right direction and I wrote a function using his principles. It works fine and does just what I want it to do THANK YOU ARRCH!

However I now have a different bug... for some reason I can't pass the integer value of the number of decimal places I want to display. Have a look at the code below. You'll notice that if I pass the number of decimal places as an argument to the function (FtoChar) I lose 0.01 in the values. But if I hard code the decimal places inside the function (FtoChar2) it works fine.

After a bit of debugging I found out where the problem is and I'm almost more confused. If you uncomment my DEBUG lines you'll notice that I get different results from what should a simple calculation of 10 to the power of 2. If I set iDigs to the value of 2 within the function I get 100 (as I should). If I pass iDigs as an argument, with the integer value of 2, to the function then 10 to the power of iDigs becomes 99 instead of 100 thereby screwing up my actual values.

Whoops. You're right PaulS I originally had returned the char as a pointer rather than passing the char as an argument. That didn't work as I wanted and when I put the char in as the argument I forgot to change the returning variable to void.

I do realise that pow() is a float (double) function. However I am unaware of any other function in Arduino which would allow me to return 10 to the power of X. Obviously I can replace it with a for loop multiplying 10 by itself X number of times. But that just seems a lot less elegant and less logical to me.

If I use pow(10,2), pow(10,4), pow(10,6), ... I always get full integer results even without doing an int(pow(10,2)), ...

However if I use pow(10,iDigs) I always get a "rounded down" result regardless of the value of iDigs.

Using pow with constants means that the compiler can pre-calculate it for you, presumably using non floating point math. Anything the arduino does with pow at runtime will be subject to rounding error.

It's a big problem when someone wants to print a floating point number by doing it the standard way and ends up with a question mark.

So the effects create problems; that doesn't mean the cause is in itself, a problem. If I write a sketch that uses 3Kb SRAM and it doesn't work, I have a problem, but that doesn't make the memory limitation "the problem".

Quote

And the problem is solved by simply checking "on" the "Enable floating point support" option in Preferences.

I don't have that option in my Arduino IDE, so apparently, it's not that simple.

Quote

I fail to see how clicking a check box is "an awful lot of work"...

What happens when IDE changes break the "fix"? Where do I go to get the updated "fix"?

Quote

If anything is awful, it's using kludges of extra code to do what a simple "%f" would do.

Oh, yes I know. It would use a few extra bytes of flash and EVERYONE'S sketch is 32767 bytes long and they just can't spare any more.

Getting people to think about other ways to approach a problem and practice their problem solving skills through critical thinking is nothing to scoff at. Stuff like this also helps highlight the limitations of the hardware and encourages to think about it while they are writing their code.

What you said makes sense, except that limitation does not exist if they use up to date hardware. The mega came out ages ago then there was the mega 2560. Now we have the DUE.

Seeing as the overall goal of Arduino is to create prototype systems that may warrant actual development I don't see why the additional detail in data(i mean floating point data) availability should be limited.

%f is a lot more intuitive and usable then the horrible kludges I read. Isn't this meant to be an easy to use platform?