Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Dec 2009
    Posts
    212
    Thanks
    36
    Thanked 0 Times in 0 Posts

    extra set of () to clarify

    Can someone please explain the reason for using an extra set of () to clarify. It was suggested to use with MAX.
    How would I do a search for this in this forum. I tried but got no returns even though this was suggested in this forum.

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts
    Could you explain the context of the extra parenthesis. What do you want to clarify? Extra sets generally will not matter. I would use them to ensure the proper order of the arithmatic or to help set something apart, but the question is content dependent....

    Steve

  3. #3
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,433
    Thanks
    371
    Thanked 1,456 Times in 1,325 Posts
    Consider:

    5+4*3/2 = 11 yes 11

    5+((4*3)/2) is how Excel sees the above. you don't need the parenthesis but it sure makes things clearer.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  4. #4
    3 Star Lounger
    Join Date
    Dec 2009
    Posts
    212
    Thanks
    36
    Thanked 0 Times in 0 Posts
    It was in reference to:
    =IF((MAX(0,TODAY()-LOOKUP(9E+300,C:C)))=0,"1st",(MAX(0,TODAY()-LOOKUP(9E+300,C:C))))
    I think the MAX was being emphasized as an option/method to avoid negative numbers.
    It appears from the 2 previous replies that it is a scripting method to highlight part of a formula or organize part of a formula to show the logic/methodology without effecting its function.

  5. #5
    5 Star Lounger
    Join Date
    Dec 2009
    Location
    East Coast, USA
    Posts
    993
    Thanks
    8
    Thanked 43 Times in 43 Posts
    Which "extra set of () to clarify" are you asking about?
    The formula =IF((MAX(0,TODAY()-LOOKUP(9E+300,C:C)))=0,"1st",(MAX(0,TODAY()-LOOKUP(9E+300,C:C)))) has two places that use () after the function TODAY(). Those parenthesis are required for the TODAY function.

  6. #6
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts
    I don't think the extra set clarifies anything. I think the 2 extra sets make it more difficult to read
    =IF((MAX(0,TODAY()-LOOKUP(9E+300,C:C)))=0,"1st",(MAX(0,TODAY()-LOOKUP(9E+300,C:C))))

    and I would eliminate them:
    =IF(MAX(0,TODAY()-LOOKUP(9E+300,C:C))=0,"1st",MAX(0,TODAY()-LOOKUP(9E+300,C:C)))

    You could also use, which seems to be clearer to me:
    =IF(TODAY()<=LOOKUP(9E+300,C:C),"1st",TODAY()-LOOKUP(9E+300,C:C))

    You don't need to use the "Max" trick to make it never less <0 if you are testing for this very condition to make it something other than zero...

    Steve

  7. #7
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    La Jolla, CA
    Posts
    1,469
    Thanks
    30
    Thanked 61 Times in 57 Posts
    When writing more complex algorithms, you can choose clarity and/or brevity. I think clarity wins every time especially if you or someone else needs to read the code in the future and a complex statement isn't documented or explained.

Posting Permissions

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