I would like to make some calculation on a raspberry pi, but I got problems with the floating point numbers
I created a simple example to demonstrate my problem
Code: Select all
chprintf((BaseSequentialStream *) &SD1, "This is an int: %d\n", 3);
chprintf((BaseSequentialStream *) &SD1, "This is a float: %f\n", 3.4);
char t[80];
float a = 342/23.0;
sprintf(t, "%f\n", a);
chprintf((BaseSequentialStream *) &SD1, t);
The output:
Code: Select all
This is an int: 3
This is a float: 0.00000
0.000000
What can be the problem?
Thanks,
Robert