LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,231
Default Understanding the objective '--' used in SUM PRODUCT function

"T. Valko" wrote...
....
The double unary is never "needed". . . .


Yup. Any idempotent arithmetic operation would do: --TF, TF+0, TF*1,
TF^1. Some arithmetic operation is needed to convert TRUE to numeric 1
and FALSE to numeric 0, and that's ALL the operation should do.

Same could be accomplished with IF(TF,1,0) or N(TF), but those both
eat a nested function call level, and the former only works in
formulas entered as array formulas, and the latter only works with
derived arrays.

What does Help say about the double unary?

It isn't even mentioned!


It shouldn't be. What should be mentioned more prominently is which
functions automatically convert their numeric string or boolean
arguments to numbers automatically and which don't. For example, my
favorite, least orthogonal function in Excel, NPV:

=NPV("100%",{1;2;3}) returns 1.375 rather than 6

and this isn't due to scalar vs array/range semantics,

=SUM("1") returns 1
=SUM({"1";"2";"3"}) returns 0

but

=NPV({"0%","100%"},{1;2;3}) returns {6,1.375} rather than {6,6}

and FTHOI

=NPV({TRUE,FALSE},{1;2;3}) returns {1.375,6} rather than {6,6}

So MSFT *COULD* have chosen to have SUMPRODUCT convert booleans and
numeric strings in entries in its array arguments into numbers, but it
didn't. Therefore, explicit type conversion is necessary, and
idempotent arithmetic operations just happen to be the most efficient
means to do that, and -- just happens to have certain benefits
compared to the alternatives. Pity unary + can't affect the same
result.

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I write up a controllers objective click New Users to Excel 1 March 15th 06 08:36 PM
Price Function - Difficulty in understanding the formula abhi_23 Excel Worksheet Functions 0 January 18th 06 09:41 AM
Is there any who can help in understanding the VLOOKUP function Ajay Excel Discussion (Misc queries) 1 October 26th 05 08:19 AM
Understanding Checkbox function Lori Burton Charts and Charting in Excel 1 July 25th 05 01:26 PM
Percent of Objective [email protected] Excel Discussion (Misc queries) 1 March 15th 05 08:12 PM


All times are GMT +1. The time now is 06:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"