samtal: Hi all, As the originator of this thread, I am overwhelmed with the magnitude of replies to a question I thought was a simple one. It looks almost like opening a Pandora's box.
Please don't worry about anything. You didn't open a "Pandora's box", nor did you ask anything wrong.
In fact, the "Pandora's box" is mostly my fault, for I get quite passionate about seeing users have problems with their programming which result from the fact that many simple, standard features and functions in C are disabled by the Arduino developers.
Now, I understand the need to minimize memory and resource usage in a small microcontroller environment, and for many cases, the disabled functions will indeed save some space.
What I gripe about is not that these features are disabled but that there is no built in ability for a user to simply "click" the feature on or off.
I've modified my Arduino IDE to provide these options (as well as a few others) so I know that programming-wise, it's trivial. Any Arduino IDE developer could add these options to the newest IDE in less than a day (probably before lunch time).
In lieu of being to optionally enable these features, there are "alternatives" for example using the function "dtostrf" to take a floating point number and convert it into a user supplied buffer, enabling the user to print fractional numbers.
Unfortunately, the sequence of events (as most everyone here has seen dozens to hundreds of times), goes like this:
(1) User writes a program to display a temperature. (2) To his surprise, any temperature is displayed as a question mark ('?'). (3) User checks and re-checks his code. Darn it looks fine!!! (4) User checks the C documentation online and finds that, yes indeed he's doing it right. (5) User then logs on here and asks about the problem. (6) User gets a flurry of responses ranging from "It can't be done" to "It's disabled to save memory" to "Use the dtostrf function". (7) Ah-ha! One positive reply... user CAN do it with dtostrf. (8) User goes online looking in C documentation for how to use dtostrf. (9) Darn! Can't seem to find anything. Back to the Arduino forum. (10) User finds out that dtostrf is an AVR specific function. (11) User looks at the Arduino documentation. Nothing found. ARGHHHHHH!!! (12) User checks online for the docs. AH! Success! (13) User reads the information.....
[b]The dtostrf() function converts the double value passed in val into an ASCII representationthat will be stored under s. The caller is responsible for providing sufficient storage in s. Conversion is done in the format "[-]d.ddd". The minimum field width of the output string (including the possible'.' and the possible sign for negative values) is given in width, and prec determines the number of digits after the decimal sign. width is signed value, negative for left adjustment. The dtostrf() function returns the pointer to the converted string s. [/b]
Yeah OK.... um what the heck does THAT mean?
(14) Another post to this forum yields a few terse examples which user tries. (15) After a few tries, the user figures out what "provide sufficient storage" means... :) (16) .....it goes on and on.......
OR!!!!!!!!! The user SHOULD be able to simply click the "Enable floating point" checkbox in Preferences, then do this:
printf ("The temperature is %5.1f degrees C\n", temperature);
...and have his sketch JUST WORK.
In fact, the above "scenario" I went through myself when I first started with the Arduino. I was not a noob... I had years of previous experience in programming assembler in Motorola and Intel, as well as programming in C and C++.
I was rather ticked off to find out how much time I wasted with that "floating point problem" and it ticks me off to see others go through the same thing simply because nobody will take a 1/2 hour and add a few options to the IDE that people ACTUALLY NEED.
That's when I get all revved up and write stuff like this.
So, please don't feel as though you did anything wrong or started any problems. You did not, and I sure hope you will continue to ask us anything you need - please feel free.