MATLAB: What does this line of code mean in non-code speak

divfalseleap yeartrue

if (div4 & ~( xor(div100, div400)))
div4 div100 and div400 are given by:
div4 = ((year/4) == floor (year/4));
div100 = ((year/100) == floor (year/100));
div400 = ((year/400) == floor (year/400));

Best Answer

div4, div100, and div400 are all logical variables, 1 or 0.
if (div4 & ~(xor(div100,div400)))
says "if div4 is true (1) and div100 and div400 are both false or both are true, do something"
~xor(div100,div400)
equals 1 (true) only if both div100 and div400 are false or both are true
Related Question