title: How can I work around the fact that in C++, sin(M_PI) is not 0?
body: <p>In C++,</p>
  
  <pre><code>const double Pi = 3.14159265;
  cout &lt;&lt; sin(Pi);                          // displays: 3.58979e-009
  </code></pre>
  
  <p>it SHOULD display the number zero</p>
  
  <p>I understand this is because Pi is being approximated, but is there any way I can have a value of Pi hardcoded into my program that will return 0 for sin(Pi)?  (a different constant maybe?)</p>
  
  <p>In case you're wondering what I'm trying to do:  I'm converting polar to rectangular, and while there are some printf() tricks I can do to print it as "0.00", it still doesn't consistently return decent values (in some cases I get "-0.00")</p>
  
  <p>The lines that require sin and cosine are:</p>
  
  <pre><code>x = r*sin(theta);
  y = r*cos(theta);
  </code></pre>
  
  <p>BTW: My Rectangular -> Polar is working fine... it's just the Polar -> Rectangular</p>
  
  <p>Thanks!</p>
  
  <p><strong>edit:</strong>  I'm looking for a workaround so that I can print sin(some multiple of Pi) as a nice round number to the console (ideally without a thousand if-statements)</p>