cancel
Showing results for 
Search instead for 
Did you mean: 

How to print float value with sprintf in TrueStudio and H7?

Gerardo Trotta
Associate II

This :

double num= 10.85

int written = sprintf(num_buf, "%1.17g", num);

works in F4 using -u _printf_float into linker commands settings.

But does not work in H7.

Any suggestions?

13 REPLIES 13

The pow() function is slow, big and doesn't guaranty exact integer result. A simple loop with integer multiplication is much faster and takes less code.

Singh.Harjit
Senior II

​I've been using this: https://github.com/mpaland/printf for my printf needs.

This one looks really nice!

Very nice, will try on my H7