+ Reply to Thread
Results 1 to 4 of 4

Thread: Operation order - bug or me?

  1. #1
    Registered User
    Join Date
    08-21-2011
    Location
    Hefei, China
    MS-Off Ver
    Excel 2007
    Posts
    2

    Question Operation order - bug or me?

    dear all,

    i really do not understand if it's me doing something silly of a special feature of Excel.
    I do not consider myself a newbie.

    I solved my problem, but I was wondering if there are some links with literature explaining a bit better these little features..

    I tried 2 expressions:

    =(-D3^2+B3^2+C3^2)/(2*B3*C3) (Exp1)

    and

    =(B3^2+C3^2-D3^2)/(2*B3*C3) (Exp2)

    with (tested) integer and double numbers in B,C,D fields

    the result is different, with the expression (Exp2) giving the correct result.



    then i tried:

    =(-(D3^2)+B3^2+C3^2)/(2*B3*C3) (Exp3)

    and finally got the same result as (Exp2)..

    so maybe I guess Excel change the sign of the field D3 before it makes it square..

    But then why (Exp2) is working???

    Do you know some links/literature explaining things like this, about how Excel handle fields in case of multiple math calculations?

    Thanks!
    Last edited by andyHefei; 08-21-2011 at 09:37 PM.

  2. #2
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007, 2010
    Posts
    25,777

    Re: Operation order - bug or me?

    The unary negation operator is the highest precedence among arithmetic operators; -3^2 = 9, not -9
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    08-21-2011
    Location
    Hefei, China
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Operation order - bug or me?

    but then why (Exp2) is ok?

    =(B3^2+C3^2-D3^2)/(2*B3*C3) (Exp2)

    is that because here the "-" is arithmetic subtraction and not unary negation operator?

    where can i find a lit of these priorities?

    thx!

  4. #4
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007, 2010
    Posts
    25,777

    Re: Operation order - bug or me?

    See Help for Calculation operators and precedence
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

+ 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.2.0