Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 6
Default Using two hyphens in front of an Excel function.

Yesterday I saw an Excel function that had two hyphens "--" before the
function name. I do remember reading about this a few months ago but I do not
remember the use. I was NOT double negation as I remember well. There was
another obscur use. Anybody has an idea?

Thanks
--
Daniel
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Using two hyphens in front of an Excel function.


To convert True to 1 and False to 0
so that maths can be done on them.


--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: http://www.thecodecage.com/forumz/member.php?userid=558
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=126935

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 7,247
Default Using two hyphens in front of an Excel function.

The double negation (changes the sign from positive to negative and
then negative to positive) is one way to convert the TRUE or FALSE
result of a comparison operation to the numeric equivalent (TRUE = 1,
FALSE = 0). Basically, it multiplies the TRUE or FALSE by -1 twice,
which forces Excel to change the value to a number.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


On Wed, 19 Aug 2009 15:12:24 -0700, dlamarche <Melbourne wrote:

Yesterday I saw an Excel function that had two hyphens "--" before the
function name. I do remember reading about this a few months ago but I do not
remember the use. I was NOT double negation as I remember well. There was
another obscur use. Anybody has an idea?

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,059
Default Using two hyphens in front of an Excel function.

"dlamarche" <Melbourne wrote:
Yesterday I saw an Excel function that had two hyphens "--" before the
function name. I do remember reading about this a few months ago but
I do not remember the use. I was NOT double negation as I remember
well. There was another obscur use. Anybody has an idea?


Yes, it __is__ simply double negation.

Sometimes it is used to convert "numeric text" or Boolean values (TRUE,
FALSE) to bona fide numbers. But any arithmetic operation will do the
trick. Double negation per se is not always necessary.

For example, consider =TEXT(A1,"hh:mm"), which might be used to round a time
value in A1 to the precision of a minute. The TEXT function itself returns
a string. If you want a time value (a number), you can use double negation,
to wit: =--TEXT(A1,"hh:mm").

But suppose you want to add 1 minute to the rounded time value. It would be
sufficient to do: =TEXT(A1,"hh:mm")+TIME(0,1,0).

PS: Even where double negation is useful, there are alternatives.
=1*TEXT(A1,"hh:mm") is equivalent to =--TEXT(A1,"hh:mm").

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 6
Default Using two hyphens in front of an Excel function.

Thanks you very much for the info gentlemen. I was very intriged but now it
is clearer. So -- was a double negation after all. Thanks Chip, I visit your
site regularly and recommended it to many of my students!

--
Daniel


"JoeU2004" wrote:

"dlamarche" <Melbourne wrote:
Yesterday I saw an Excel function that had two hyphens "--" before the
function name. I do remember reading about this a few months ago but
I do not remember the use. I was NOT double negation as I remember
well. There was another obscur use. Anybody has an idea?


Yes, it __is__ simply double negation.

Sometimes it is used to convert "numeric text" or Boolean values (TRUE,
FALSE) to bona fide numbers. But any arithmetic operation will do the
trick. Double negation per se is not always necessary.

For example, consider =TEXT(A1,"hh:mm"), which might be used to round a time
value in A1 to the precision of a minute. The TEXT function itself returns
a string. If you want a time value (a number), you can use double negation,
to wit: =--TEXT(A1,"hh:mm").

But suppose you want to add 1 minute to the rounded time value. It would be
sufficient to do: =TEXT(A1,"hh:mm")+TIME(0,1,0).

PS: Even where double negation is useful, there are alternatives.
=1*TEXT(A1,"hh:mm") is equivalent to =--TEXT(A1,"hh:mm").




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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel sort ( exclude letters include hyphens)? always confused Excel Worksheet Functions 5 July 2nd 08 01:46 AM
How to keep 0 in front of # in excel (ex: 018787766316) Rob Excel Worksheet Functions 3 August 19th 06 07:18 PM
how do i remove telephone number hyphens from a list in Excel? Mediazoo Excel Discussion (Misc queries) 4 November 3rd 05 08:29 PM
Does XL2K have "hard hyphens" (non-break hyphens)? StargateFan Excel Discussion (Misc queries) 0 January 29th 05 01:36 PM
excel front end to access Steve Peterson Excel Discussion (Misc queries) 1 January 20th 05 10:31 PM


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