Steve, > cycles = 597.65625ms. Find the smallest integer constants A and B > such that (A+B)*600 = A*601.56125 + B*597.65625. If A and/or B are too > large, pick different loop times. Ideally, one of A or B should be > 1 since this simplifies the loop logic. > > [Anyone got a good algorithm for finding A and B?] The smallest integer solution to the Diophantine equation ax-by=0 (a,b>0) is (x,y) = (b/gcd(a,b), a/gcd(a,b)). I your case, (A+B)*600 = A*601.56125 + B*597.65625 <=> 1.56125 A = 2.34375 B <=> 249 A = 375 B The smallest solution is (A,B) = (375,249), since gcd(249,375)=1. Close, but not exact, is (A,B) = (3,2), since 249 is near 250. (A good way to find approximate solutions with small integers is to truncate the continued fractions expansion of a/b. In some reasonable sense this gives the "best" possible approximation, but I guess you don't need this here.) -- Martin Martin Nilsson http://www.sics.se/~mn/ Swedish Institute of Computer Science E-mail: mn@sics.se Box 1263, S-164 28 Kista Fax: +46-8-751-7230 Sweden Tel: +46-8-752-1574