I'm new to C, and am trying to make sense of some code from NREL available here so that I may program a similar function in R. Here's the part of the code I cannot seem to figure out:
long S_solpos (struct posdata *pdat)
{
if ( pdat->function & L_DOY )
doy2dom( pdat );
}
In particular, what is the evaluation criteria asking in:
if ( pdat->function & L_DOY )
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:
struct posdata
{
int function;
and that L_DOY can be one such function:
/*Define the function codes*/
#define L_DOY 0x0001
#define L_GEOM 0x0002
#define L_ZENETR 0x0004
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.
Thanks in advance for any help.