Hi Kevin, On Wednesday, 2012-02-29 15:38:30 +0100, Kevin André 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);
While giving the correct result this unnecessarily evaluates the expression ((nYear % 400) == 0) in 3/4 of all cases and then continues with evaluation of ((nYear % 4) == 0) just to return then if false, whereas starting with ((nYear % 4) == 0) does not need any further evaluation in 3/4 of all cases. Apart from that, parentheses IMHO increase readability of logical expressions. With more complicated expressions they also help if the editor supports highlighting / jumping matching parentheses. Eike -- LibreOffice Calc developer. Number formatter stricken i18n transpositionizer. GnuPG key 0x293C05FD : 997A 4C60 CE41 0149 0DB3 9E96 2F1A D073 293C 05FD
Attachment:
pgpYNZAZXfH4u.pgp
Description: PGP signature