Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Find the Largest of 3 Values

  • Dan Ebberts

    June 27, 2012 at 1:18 pm

    I think this works too:

    Math.min(Math.min(Math.max(a,b),Math.max(a,c)),Math.max(b,c))

    Dan

  • Walter Soyka

    June 30, 2012 at 1:14 am

    Here’s an alternate approach, using arrays and the sort() method. First, stuff each of the values into an unsorted array. Next, sort the array. Finally, return the value of the last item in the array, which will be the highest value because we just sorted it.

    unsortedArray = [a,b,c];
    sortedArray = unsortedArray.sort();
    sortedArray[sortedArray.length-1];

    To get the middle value, replace the final line with:sortedArray[Math.round(sortedArray.length/2)-1];

    To get the lowest value, replace the final line with:sortedArray[0];

    You can shorten it, too, removing the assignment:
    myArray = [a,b,c];
    myArray.sort()[sortedArray.length-1];

    Walter Soyka
    Principal & Designer at Keen Live
    Motion Graphics, Widescreen Events, Presentation Design, and Consulting
    RenderBreak Blog – What I’m thinking when my workstation’s thinking
    Creative Cow Forum Host: Live & Stage Events

Page 2 of 2

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy