Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: Slightly OT -- Fast Divide By 10

2004-11-30 by Karl Olsen

--- In lpc2000@yahoogroups.com, "James Dabbs" <jdabbs@t...> wrote:
> 
> I'm trying to squeeze a few more cycles out of one my LPC, and I'm
> looking for an optimized way to divide by 10 and leave the quotient 
and
> remainder.  I.e., a faster way to do this:
> 
> #define DIVIDE_BY_10(D, Q, R) Q=D/10; R=D%10;  // D is unsigned long


Check out "How to optimize for the Pentium family of microprocessors"
http://www.agner.org/assem/pentopt.pdf

The section "Division (all processors)" has a smart algorithm for 
converting division by a constant to a cheaper multiplication and 
shift.

Karl Olsen

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.