R
rh
Dr said:JRS: In article
dated Sat, 12 Feb 2005 18:06:26, seen in rh
It would be more readable, and might be better, to work along the lines
of (/* ++ */ implies conversion of range 1..12 to 0..11)
daysInMo = /* ++ */ m==2 ? expression(y) : expression(m)
++m==2 ? 28 + !(y&3 || y&15 && !(y%25)) : 28 | m>>3^m|2 }
or 28 | ( ++m==2 ? !(y&3 || y&15 && !(y%25)) : m>>3^m|2 ) }
which seem slightly faster than
28 | ( m^1 && ++m>>3^m|2 || !(y&3 || y&15 && !(y%25)) )
Right, but if utmost speed is the predominant criteria, then Lasse's
method is really the one of choice.
Also, in terms of speed of the above, I believe I can provide another
incarnation which brings a similar marginal speed advantage over the
tertiary form, and provides a clearer separation of the Feb
calculation.
But it all depends on what the goal is. Mine, in this case, happened to
be to achieve a succinct, efficient computation by taking an
interesting departure from the usual arithmetical approach in producing
a result. And I think it's good that some may wonder how that somewhat
obscure expression can possibly provide the correct result. Those
wishing to find out, aren't going to get much of a leg up with it
converted to tertiary form, which necessarily removes some of the
intentional bit mangling shortcut logic.
Your criteria may, and quite likely will, differ.
../rh