From: EDWARD CASHIN Message-Id: <199807271629.MAA14391@woodstock.cs.uga.edu> Subject: implementation of modulo operator in djgpp To: djgpp AT delorie DOT com Date: Mon, 27 Jul 1998 12:29:10 -0400 (EDT) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk Hello. I was just considering the case of a circular buffer. Indexing the subscripts could be done with something like this: /* subscripts: "front" is subscript of first stored value "back" is subscript of last stored value "last" is subscript of the last available array spot */ front = (front + 1 > last) ? 0 : front + 1; back = (back + 1 > last) ? 0 : back + 1; ...or you could say: front = (++front) % last; back = (++back) % last; ...which begs the question, "How fast is the modulo?" and more specifically, how is it implemented? Thanks, --Ed