Re: >> to accelerate division

From: Ben Pfaff (blp_at_cs.stanford.edu)
Date: 12/08/04


Date: Tue, 07 Dec 2004 19:34:15 -0800


"Mysidia" <mysidia@gmail.com> writes:

> If you can figure out a way of expressing i / 3 as bit shifts,
> then you have an improvement.
> But I am doubting there is a way, without doing the full divide.

You can implement i/3 as a multiplication followed by a bit
shift. In some cases this may be an improvement. However, if it
is an improvement, your compiler may already be doing it for you.

See chapter 10 of Warren, Jr., _Hacker's Delight_, Addison-Wesley
2003, ISBN 0-201-91465-4, for details.

-- 
Ben Pfaff 
email: blp@cs.stanford.edu
web: http://benpfaff.org


Relevant Pages

  • Re: >> to accelerate division
    ... "Mysidia" writes: ... > But I am doubting there is a way, without doing the full divide. ... You can implement i/3 as a multiplication followed by a bit ...
    (comp.programming)
  • Re: >> to accelerate division
    ... "Mysidia" writes: ... > But I am doubting there is a way, without doing the full divide. ... You can implement i/3 as a multiplication followed by a bit ...
    (comp.lang.c)
  • Re: >> to accelerate division
    ... Ben Pfaff writes: ... >> But I am doubting there is a way, without doing the full divide. ... 15, 44793 Bochum ...
    (comp.programming)
  • Re: >> to accelerate division
    ... Ben Pfaff writes: ... >> But I am doubting there is a way, without doing the full divide. ... 15, 44793 Bochum ...
    (sci.math)
  • Re: >> to accelerate division
    ... Ben Pfaff writes: ... >> But I am doubting there is a way, without doing the full divide. ... 15, 44793 Bochum ...
    (comp.lang.c)