Hello RIOT Team,
1 Question:
I try to calculate some floating point digits on the SAMR21-xpro Board. When I print the floating point digit it shows me nothing.
My Code:
Hello RIOT Team,
1 Question:
I try to calculate some floating point digits on the SAMR21-xpro Board. When I print the floating point digit it shows me nothing.
My Code:
Hi Oliver,
See my answer about printf below. I'm not enough expert with timer accuracy but there are known issues with xtimer, maybe have a look at related issues/PRs on github ?
1 Question:
I try to calculate some floating point digits on the SAMR21-xpro Board. When I print the floating point digit it shows me nothing.
My Code:
uint32_t time_diff = 554;
double distance = (33./2000.) * time_diff; printf("distance = %f cm\n",distance);
Output:
2019-07-31 14:36:58,631 - INFO # distance = cm
Stack Overflow [1] tells me that floating point are disabled by default on arm-gcc. Whats the trick ?? What should I add to the Makefile ?
Just add USEMODULE += printf_float to your application Makefile. Note that this will noticeably increase the generated firmware size.
Alex
Can somebody explain, why it increases the size so much? I have a rough idea, but would be nice to get an explanation
Hi,
Can somebody explain, why it increases the size so much? I have a rough idea, but would be nice to get an explanation
printf_float also enables double printf support, and because they are always referenced by printf through the format specifier handler, that cannot be garbage collected.
Double arithmetic is mostly done in software, and in a standard compliant way (IEEE754?), so that's expensive.
Here's what's added by just adding USEMODULE += printf_float to hello_world:
https://gist.github.com/7eb71763f81908a2d0f8f90f94ac63c5
Kaspar