What does y -= m < 3 mean?

后端 未结 8 2052
面向向阳花
面向向阳花 2021-01-30 20:03

While looking through some example C code, I came across this:

y -= m < 3;

What does this do? It it some kind of condensed for loop or som

8条回答
  •  情话喂你
    2021-01-30 20:41

    I means if (m < 3) { y -=1; }, since (m < 3) is 1 if m is less than 3, 0 otherwise.

    The code appears in some hoary old reference implementation of something to do with either leap years or Easter, or possibly both: the first two months January and February are special because they occur before the leap day. There isn't really any excuse for writing code like that, unless you actually like the look of it. Most people don't.

提交回复
热议问题