title: Use of ampersands in C if statement criteria
body: <p>I'm new to C, and am trying to make sense of some code from NREL <a href="http://rredc.nrel.gov/solar/codesandalgorithms/solpos/solpos.c" rel="nofollow">available here</a> so that I may program a similar function in R. Here's the part of the code I cannot seem to figure out:</p>
  
  <pre><code>long S_solpos (struct posdata *pdat)
  {
  
  if ( pdat-&gt;function &amp; L_DOY )
      doy2dom( pdat );     
  }
  </code></pre>
  
  <p>In particular, what is the evaluation criteria asking in:</p>
  
  <pre><code>if ( pdat-&gt;function &amp; L_DOY )
  </code></pre>
  
  <p>I understand that pdat is a is a pointer to the posdata structure, and from the header file I know that that "function" is a variable in the posdata structure which contains various integer codes:</p>
  
  <pre><code>struct posdata
  {
  int   function;
  </code></pre>
  
  <p>and that L_DOY can be one such function:</p>
  
  <pre><code>/*Define the function codes*/
  #define L_DOY    0x0001
  #define L_GEOM   0x0002
  #define L_ZENETR 0x0004
  </code></pre>
  
  <p>I would assume that the if statement is checking whether the function variable within pdat corresponds to the code for L_DOY. However, I am still very new to C, and have been unable to find any examples or explanations that utilize the ampersand in an if statement like this.</p>
  
  <p>Thanks in advance for any help.</p>