• extra set of () to clarify

    Author
    Topic
    #477510

    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.

    Viewing 5 reply threads
    Author
    Replies
    • #1285906

      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

    • #1285916

      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.:cheers:

      May the Forces of good computing be with you!

      RG

      PowerShell & VBA Rule!
      Computer Specs

    • #1285944

      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.

    • #1285946

      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.

    • #1285950

      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

    • #1286014

      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.

    Viewing 5 reply threads
    Reply To: extra set of () to clarify

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: