title: Printf for float in c
body: <p>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?</p>
  
  <p>code :</p>
  
  <pre><code>  float dist = 2.0*3.14*0.25*count;
  
    printf("counter : %d\n",count);
    printf("dist : %f\n", dist);
  </code></pre>
  
  <p>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: </p>
  
  <pre><code>dist : f
  counter : 12
  dist : f
  counter : 12
  dist : f
  counter : 12
  dist : f
  counter : 12
  dist : f
  counter : 12
  dist : f
  </code></pre>
  
  <p>Even if i try printing 0.25 like: </p>
  
  <pre><code>printf("%f\n",0.25);
  </code></pre>
  
  <p>it gives me the output "f"
  <a href="https://i.stack.imgur.com/j8t4e.png" rel="nofollow noreferrer">here 's the compiler output</a></p>
  
  <p>Tested this, but it didn't worked:</p>
  
  <pre><code>    char b[10];
  
      uint32_t dist = b_radious*counter*M_PI*2.0f;
  
      dist = (dist + 1) &gt;&gt; 1;
  
      unsigned units = dist/1000;
      unsigned fraction = dist - (dist*1000);
  
      sprintf(b, "%4u.%03u", units, fraction);
  </code></pre>