I'm actually trying to print a float in c using atmel std and instead of printing the value , it gives me just "f". Anyone knows why it's like this?
code :
float dist = 2.0*3.14*0.25*count;
printf("counter : %d\n",count);
printf("dist : %f\n", dist);
so, counter's actually a volatile long that updates after a button click on my hardware, consider it's working, the print of it's correct, but the print of dist's not correct, it gives me this:
dist : f
counter : 12
dist : f
counter : 12
dist : f
counter : 12
dist : f
counter : 12
dist : f
counter : 12
dist : f
Even if i try printing 0.25 like:
printf("%f\n",0.25);
it gives me the output "f" here 's the compiler output
Tested this, but it didn't worked:
char b[10];
uint32_t dist = b_radious*counter*M_PI*2.0f;
dist = (dist + 1) >> 1;
unsigned units = dist/1000;
unsigned fraction = dist - (dist*1000);
sprintf(b, "%4u.%03u", units, fraction);