What does this line of code mean in non-code speak?
Show older comments
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));
Accepted Answer
More Answers (2)
Roger Stafford
on 16 Jun 2013
In other words, this logical statement is true when 'year' is to be a leap year under the Gregorian calendar. They could just as well have written
if div4&(div100==div400)
or, given the definitions of these quantities,
if div4&(div100<=div400)
or, again given their definitions, even this
if div400|(div4~=div100)
Andrei Bobrov
on 16 Jun 2013
~rem(year,4)&rem(year,100)|~rem(year,400)
Categories
Find more on Calendar in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!