cmp(A,B) swapif(A>B) cmp(B,C) swapif(B>C) cmp(A,B) swapif(A>B) B is middle value -----Original Message----- From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu]On Behalf Of Mark Rages Sent: Friday, July 15, 2005 8:24 PM To: Microcontroller discussion list - Public. Subject: Re: [PIC] Design Challenge: Find center of three values On 7/15/05, Mark Rages wrote: > I'll post my solution in a minute, once I'm satisfied it works. Well, I think it's working and it's quitting time, so here goes: I started by listing all the possibilities: A > B > C choose B A > C > B choose C B > A > C choose A B > C > A choose C C > A > B choose A C > B > A choose B I notice that there are really only three comparisons, if we ingnore equality. (After all, if A=B, it doesn't matter which I choose.) -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist