Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 293
Default What Does -- Mean?

Greetings,

What does the double minus (--)sign in front of a command signify?

-Minitman
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,311
Default What Does -- Mean?

A double minus is also known as a double urnary.

In this formula: =SUMPRODUCT(--(A1:A10 & D1:D10="1A"))

this section: (A1:A10 & D1:D10="1A")
returns a series of boolean (fancy word for: TRUE/FALSE) values
....which are not numeric to Excel.

When an arithmetic operator (+,-,*,/) is applied to a boolean value,
Excel converts TRUE to 1 and FALSE to 0.

The standard convention is to use
the Double-Minus (--) to convert the values.
It works this way:
TRUE=TRUE
-TRUE = -1
--TRUE = 1

FALSE = FALSE
-FALSE = 0
--FALSE = 0

Now, you could easily use 1*TRUE, but the Dbl-Minus indicates to
knowledgable users that you are forcing a conversion and not
trying to calculate something.

So, In the formula, the TRUE/FALSE values are converted to 1's and 0's
by the "--" and the SUMPRODUCT calculates the total.

- explanation contribution thanks to Ron Coderre from a previous post


--

"Minitman" wrote in message
...
Greetings,

What does the double minus (--)sign in front of a command signify?

-Minitman



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 293
Default What Does -- Mean?

Thanks PCLIVE,

That is indeed advanced stuff.

I still don't fully understand it, but now the understanding is
flittering at the edge of my understanding and will alight on me when
I least expect it.

Again, thanks.

-Minitman



On Tue, 10 Jun 2008 14:48:45 -0400, "PCLIVE"
wrote:

A double minus is also known as a double urnary.

In this formula: =SUMPRODUCT(--(A1:A10 & D1:D10="1A"))

this section: (A1:A10 & D1:D10="1A")
returns a series of boolean (fancy word for: TRUE/FALSE) values
...which are not numeric to Excel.

When an arithmetic operator (+,-,*,/) is applied to a boolean value,
Excel converts TRUE to 1 and FALSE to 0.

The standard convention is to use
the Double-Minus (--) to convert the values.
It works this way:
TRUE=TRUE
-TRUE = -1
--TRUE = 1

FALSE = FALSE
-FALSE = 0
--FALSE = 0

Now, you could easily use 1*TRUE, but the Dbl-Minus indicates to
knowledgable users that you are forcing a conversion and not
trying to calculate something.

So, In the formula, the TRUE/FALSE values are converted to 1's and 0's
by the "--" and the SUMPRODUCT calculates the total.

- explanation contribution thanks to Ron Coderre from a previous post


Reply
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



All times are GMT +1. The time now is 08:50 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"