try this! for (i=0;i data[i+1]) { return data[i]; } } return data[i]; -Craig Beiferman ______________________________ Reply Separator _________________________________ Subject: challenge - which number is higher Author: pic microcontroller discussion list at INTERNET Date: 11/30/99 2:17 PM I have an interesting problem that I'd like to throw to the gurus. I am storing a number of records in eeprom - kind of a circular buffer arrangement. Part of each record is a 1 byte number used as a 'sequence' counter - its purpose is to tell me which record is the newest. The counter will start at 00, increment to FF, then roll over back to 00. This is the challenge: how to tell which number is highest. The records are stored in a fixed sequence, with the oldest record being overwritten by the current record. Again, the sequence number is part of the record being stored. When the system powers up, I need to retreive the newest record and stick it into RAM. Eg. Read the sequence number from 8 records and find the most recent record. 00 01 02 03 04 05 06 07 (easy) F9 FA FB FC FD FE FF 00 (harder) FE FF 00 01 02 03 04 05 (harder) The problem is dealing with the wrap from FF to 00. Thoughts, ideas? dwayne Dwayne Reid Trinity Electronics Systems Ltd Edmonton, AB, CANADA (780) 489-3199 voice (780) 487-6397 fax Celebrating 15 years of Engineering Innovation (1984 - 1999) * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Do NOT send unsolicited commercial email to this email address. My posting messages to Usenet neither grants consent to receive unsolicited commercial email nor is intended to solicit commercial email.