Float to string conversion

Hi! I'm using a Arduino Teensy 3.1 and I need to convert floats to strings so I can send it by I2C. The problem is I can't find a function to do so.

I tried with snprintf but I loose the decimals in the conversion and the sign of the number... Anyone knows how to do this?


Doesn't work with teensy 3.1...

Isn't that a question for the Teensy forum?

OK Here's a bit of a kludge.

void floatToString(char *buffer, float value)
int units=value;
int hundredths=value * 100;
hundredths = hundredths % 100;
sprintf(buffer,"%d.%d", units, hundredths);
sprintf(buffer,"%d.%02d", units, hundredths);


AWOL: sprintf(buffer,"%d.%02d", units, hundredths);


I did say it was a kludge didn't I :)

Why don't you send the float by I2C ?