title: In C, tan(30) gives me a negative value! Why?
body: <p>I observe that my <strong><code>tan(float)</code></strong> function from the <strong><code>cmath</code></strong> library is returning a negative value.</p>
  
  <p>The following piece of code, when run :</p>
  
  <pre><code>    #include &lt;cmath&gt;
      ....
  
      // some calculation here gives me a value between 0.0 to 1.0.
      float tempSpeed = 0.5; 
  
      float tanValue = tan(tempSpeed * 60);
  
      __android_log_print(ANDROID_LOG_INFO, "Log Me", "speed: %f", tanValue);
  </code></pre>
  
  <p>Gives me this result in my Log file:</p>
  
  <pre><code>    Log Me: speed `-6.4053311966`
  </code></pre>
  
  <p>As far as I remember </p>
  
  <pre><code>    tan(0.5*60) = tan(30) = 1/squareroot(3);
  </code></pre>
  
  <p>Can someone help me here as in why I am seeing a negative value? Is it related to some floating point size error? Or am I doing something really dumb?</p>