This is getting a little off topic, but: "John Payson" wrote: > division. I think many, including C, mandate that > > X = X*(X div Y) + (X mod Y) > > for all (X,Y) > (0,0) but neither the round-to-zero nor round-to-lowest > semantics are mandated for X<0 or Y<0. This is partially true; the ANSI C standard does allow that an implementation may round a negative result down, rather than towards zero, when using the / operator. This was, however, introduced solely to avoid a gross slowdown on bizarre hardware. The committee wanted to make integer division well-defined, but compromised by defining the div() and ldiv() functions, which round towards zero. See the ANSI C Rationale, section 3.3.5. I think this had best be concluded by saying that a signed right shift does implement an operation that can be labelled "division", but that most people would be surprised by the result of (-1)/2 in this case. Where a particular application can accept rounding towards negative infinity, use of a right shift for signed division may be a fast solution. Clyde -- Clyde Smith-Stubbs | HI-TECH Software, | Voice: +61 7 3300 5011 clyde@hitech.com.au | P.O. Box 103, Alderley, | Fax: +61 7 3300 5246 http://www.hitech.com.au | QLD, 4051, AUSTRALIA. | BBS: +61 7 3300 5235 ---------------------------------------------------------------------------- For info on the World's best C cross compilers for embedded systems, point your WWW browser at http://www.hitech.com.au, or email info@hitech.com.au