Hi Everyone, a trying to convert a float to string using
String(1.125,3) and i obtain this
Call of overloaded 'String(double &, int)' is ambiguous
I using Arduino 1.05-r2
Thanks!!
Hi Everyone, a trying to convert a float to string using
String(1.125,3) and i obtain this
Call of overloaded 'String(double &, int)' is ambiguous
I using Arduino 1.05-r2
Thanks!!
Hi Everyone, a trying to convert a float to string using
My first question would be why ?
The conversion works for me with the same IDE version but it is not obvious how you have tried to do the conversion. Please post the whole program.
The error talks about a reference to double, not a double constant, so perhaps that is not
the actual code you used?
This is my code
void setup()
{
Serial.begin(9600);
}
void loop() {
String stringOne = "";
stringOne = String(5.698, 3);
Serial.println(stringOne);
while (true);
}
I obtain
Call of overloaded 'String(double,int)' is ambiguous
It compiles for me. Uno, IDE 1.5.6-r2, Windows 7
Why do you want to do the conversion anyway ?
The String class brings a lot of convenience to the party, but at a pretty heavy memory cost. Your code compiled fine for me (IDE1.6.5) and generated 4996 bytes. The code here:
void setup()
{
Serial.begin(9600);
}
void loop() {
char stringOne[10];
dtostrf(5.698, 8, 3, stringOne);
Serial.println(stringOne);
while (true);
}
does the same thing, but uses 3338 bytes of code. In most cases, a string of chars is going to use less memory.
I am very grateful Econjack, that's works good. Thank you!
UKHeliBob, I'm working with an accelerometer and i need send the aceleration like a string.
thaks for you help
i need send the aceleration like a string.
Do you mean s string (a zero terminated array of chars) or a String (an object created using the String library) ?
pacomoib:
and i need send the aceleration like a string.
Perhaps something as simple as Serial.println(accelerationVal);
...R