+ Reply to Thread
Results 1 to 4 of 4

Why use "--" in formulas?

  1. #1
    Registered User
    Join Date
    03-28-2010
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    60

    Why use "--" in formulas?

    I see folks all the time showing formulas with "--" in them, such as =(--sum(.... What is the purpose of this? I assume something to do with absolute value but I am unsure.

    Thanks for the insights!
    Last edited by learning_vba; 08-08-2011 at 12:53 PM. Reason: Solved ("--" forces strings to text for calculations)

  2. #2
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Why use "--" in formulas?

    This link gives a good explanation

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Why use "--" in formulas?

    On that page given above, search for double unary operator, that's what this is typically called.
    Last edited by JBeaucaire; 08-08-2011 at 01:15 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    2003, 2007, 2010, 2013
    Posts
    1,252

    Re: Why use "--" in formulas?

    Hi,

    I'll just add some colour to the terminology.
    Unary means the operator operates on one operand. Double means that there are two operators. So, this would also be an example of a "double unary operator":
    x%%

    There are a few unary, arithmetic operators in Excel: -, % and + (which has no effect on the stack).

    -- , in the context of --x, is a pair of unary minus operators. My take on it is here (curtosy of Nate Oliver). What is -- used for? It's used to coerce non-numeric types (such as strings representing numbers or logicals) into numbers.
    Last edited by Colin Legg; 08-08-2011 at 01:25 PM.
    Hope that helps,

    Colin

    RAD Excel Blog

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1