Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
12 years, 9 months ago.
Sending a float across a serial connection _
i need to send float from the pc and recieve float from mbed.
1 Answer
12 years, 9 months ago.
Hi Rouabhia,
This thread probably has what you need:
Andy's solution is a neat and standard way:
typedef union _data {
float f;
char s[4];
} myData;
#include "mbed.h"
Serial pc(USBTX, USBRX);
myData q;
int main() {
q.f = 1.234;
pc.printf("%c%c%c%c", q.s[0], q.s[1], q.s[2], q.s[3]);
}
Simon