I don't think there's a cunning way to do it. It demands a minimum of 2 comparisons, max 3. Sorting 4 or more you'd want to use a function call or you'd have a lot of messy and confusing code (this is confusing enough). Best pseudo code I can do: IF B >= A GOTO BA IF C >= A GOTO A ; A > B if C >= A then C >= A > B IF C >= B GOTO C ; A > B and A > C if C >= B then A > C >= B ; A > B, A > C and B > C therefore A > B > C B ANSWER B GOTO END BA IF C >= A GOTO BACA ; B >= A ; B >= A > C A ANSWER A GOTO END BACA IF C >= B GOTO B ; B > A, C > A if C >= B then C >= B > A ; B > A, C > A and B > C therefore B > C > A C ANSWER C END Regards, Dan ----- Original Message ----- From: "Mark Rages" To: Sent: Saturday, July 16, 2005 6:26 AM Subject: [PIC] Design Challenge: Find center of three values > Here's a design challenge for you guys: > > I have values in three file registers: fileA, fileB, fileC. > > I want to choose the value that's in the middle (numerically) and put it > into W. > > The brute-force way to do this would be to copy the list, sort the > copy in place, and choose the middle value. > > I'm sure there's a more direct way. Any ideas? > > (Application: This a simple nonlinear filter to remove occasional > outliers in a sampled data stream.) > > Regards, > Mark > markrages@gmail > -- > You think that it is a secret, but it never has been one. > - fortune cookie > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist