Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


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@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;

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

-- 
Lionel

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.