View Single Post
  #19   Report Post  
Posted to microsoft.public.excel.programming
Peter T[_8_] Peter T[_8_] is offline
external usenet poster
 
Posts: 88
Default Sum product formula with conditions

"dpb" wrote in message
On 7/19/2019 12:52 PM, Peter T wrote:
...

I wouldn't want to discourage your use of the N function, however I
would
suggest others new this to consider using the 'double unary' as more
efficient.

...

How so?


Double unary is more direct; - the N() function has to evaluate and so
carries that extra overhead.


I seriously doubt one could measure the difference in comparison to the
rest of the function--and the two negation operations are probably as
costly as the one store--in fact, good possibility the code boils down to
the same thing in the end.


In typical usage yes of course the difference is trivial, both in terms of
storage and efficiency. However repeated in many 1000s of cells where a
sheet recalc can take seconds, or a simulation which could take miutes if
not hours the difference could be significant.

The "--" is a pair of operators, but the N calls a function which does a
whole bunch of stuff only to replicate the double -

One more function reference is in the noise level of the spreadsheet and
(imo) the clarity of intent is far more important for maintainability of
code going forward.


Clarity is subjective. You happen to know what the rarely used N function
does and when you see it know why it's there, great. But most don't, so
might look it up but then it wouldn't explain its purpose in context.
'Personally' when making a similar formula and at first it fails, easier
remember it needs the -- than the name of a function.


MS gave you a function for the job, use it... :)


Sure, if you want, but understand why it's needed. FWIW MS 'gave us' that
function not because it was needed in Excel but for compatibility with Lotus
123 & Quatro Pro, at a time when they were both better products than Excel.

FWIW I occasionally use the N to add a comment in a formula, eg
=1+2 +N("one + two")

Peter T