[REVIEWED 3-5-1][PATCH] Fix leap year calculation

Kevin André hyperquantum at gmail.com
Wed Feb 29 13:59:02 PST 2012


On Wed, Feb 29, 2012 at 18:07, Lionel Elie Mamane <lionel at mamane.lu> wrote:
> On Wed, Feb 29, 2012 at 03:38:30PM +0100, Kevin André wrote:
>> On Wed, Feb 29, 2012 at 14:56, Lionel Elie Mamane <lionel at mamane.lu> wrote:
>>> On Tue, Feb 28, 2012 at 10:10:10PM -0500, Kohei Yoshida wrote:
>
>>>>      return ((nYear % 4) == 0)
>>>> -        && !(((nYear % 100) == 0) || ((nYear % 400) == 0));
>>>> +        && (((nYear % 100) != 0) || ((nYear % 400) == 0));
>
>> Why still that many parentheses? Couldn't it be simply:
>
>> return (nYear % 400) == 0 || ((nYear % 4) == 0 && (nYear % 100) != 0);
>
> Even stronger, given the precedence of the operators in play, it could
> be:
>
>  return nYear % 400 == 0 || nYear % 4 == 0 && nYear % 100 != 0;

Yeah, I know.

> But that may be less readable... These parentheses are a trade-off
> between conciseness and readability, i.e. of style.

True. That's why I left a minimum amount of parentheses for
readability. But too many parentheses, as in the original, is also bad
for readability IMO.


Regards,

Kevin André


More information about the LibreOffice mailing list