DSPRelated.com
Forums

Divide a Number by 3

Started by rohini June 24, 2006
Hey Guys!

I am new to this group.......my name is rohini. I would like to
know..given a number say X(Binary) how would we divide it by 3(Binary).
Using either a Shifter or MAC(Multiply Accumulate).

Thanks in Advance,
Rohini.


rohini wrote:
> Hey Guys! > > I am new to this group.......my name is rohini. I would like to > know..given a number say X(Binary) how would we divide it by 3(Binary). > Using either a Shifter or MAC(Multiply Accumulate). > > Thanks in Advance, > Rohini.
Multiply by 0.33333333333333 Use as much precision as neceesary for your desired result. Clay
Clay wrote:

> rohini wrote:
>>I am new to this group.......my name is rohini. I would like to >>know..given a number say X(Binary) how would we divide it by 3(Binary). >>Using either a Shifter or MAC(Multiply Accumulate).
> Multiply by 0.33333333333333
I would multiply by 0.01010101010101010101010101... (in binary) N shifters and N adders should get you 2*2**(N+1) bits. Since the shifts are constants, they don't really use any logic, though the adders do. -- glen
"glen herrmannsfeldt" <gah@ugcs.caltech.edu> wrote in message 
news:asednZpjRveAowPZnZ2dnUVZ_rydnZ2d@comcast.com...
> Clay wrote: > >> rohini wrote: > >>>I am new to this group.......my name is rohini. I would like to >>>know..given a number say X(Binary) how would we divide it by 3(Binary). >>>Using either a Shifter or MAC(Multiply Accumulate). > >> Multiply by 0.33333333333333 > > I would multiply by 0.01010101010101010101010101... (in binary) > > N shifters and N adders should get you 2*2**(N+1) bits. > Since the shifts are constants, they don't really use any > logic, though the adders do. > > -- glen >
Easier to add 1 + 1/2 (hardwired shift) then mult by 2 (hardwired shift). 1 adder required. Slurp
Slurp wrote:
> "glen herrmannsfeldt" <gah@ugcs.caltech.edu> wrote in message > news:asednZpjRveAowPZnZ2dnUVZ_rydnZ2d@comcast.com... >> Clay wrote: >> >>> rohini wrote: >>>> I am new to this group.......my name is rohini. I would like to >>>> know..given a number say X(Binary) how would we divide it by 3(Binary). >>>> Using either a Shifter or MAC(Multiply Accumulate). >>> Multiply by 0.33333333333333 >> I would multiply by 0.01010101010101010101010101... (in binary) >> >> N shifters and N adders should get you 2*2**(N+1) bits. >> Since the shifts are constants, they don't really use any >> logic, though the adders do. >> >> -- glen >> > > Easier to add 1 + 1/2 (hardwired shift) then mult by 2 (hardwired shift). > > 1 adder required.
Isn't it the same as adding 2x + 1x? I see how that multiplies by 3, but division is wanted. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
rohini wrote:
> Hey Guys! > > I am new to this group.......my name is rohini. I would like to > know..given a number say X(Binary) how would we divide it by 3(Binary). > Using either a Shifter or MAC(Multiply Accumulate). > > Thanks in Advance, > Rohini. > >
Hey Rohini, I've never done this myself but why not subtract the divisor from the dividend until done? You've got simple hardware... Mike
>>>>> "Clay" == Clay <physics@bellsouth.net> writes:
Clay> rohini wrote: >> Hey Guys! >> >> I am new to this group.......my name is rohini. I would like to >> know..given a number say X(Binary) how would we divide it by 3(Binary). >> Using either a Shifter or MAC(Multiply Accumulate). >> >> Thanks in Advance, >> Rohini. Clay> Multiply by 0.33333333333333 Clay> Use as much precision as neceesary for your desired result. It is, in fact, possible to find a "reciprocal" such that when you multiply it by X, you get the exact (scaled) quotient of X/3, from which an exact remainder can also be calculated. Don't know if that's what is wanted or some good enough approximation to X/3. Ray
glen herrmannsfeldt wrote:
> Clay wrote: > > > rohini wrote: > > >>I am new to this group.......my name is rohini. I would like to > >>know..given a number say X(Binary) how would we divide it by 3(Binary). > >>Using either a Shifter or MAC(Multiply Accumulate). > > > Multiply by 0.33333333333333 > > I would multiply by 0.01010101010101010101010101... (in binary)
Cool. This formula can also be used for the compass-and-straight-edge trisection of an angle.
On 24-Jun-2006, "rohini" <rohini.k4@gmail.com> wrote:

> Hey Guys! > > I am new to this group.......my name is rohini. I would like to > know..given a number say X(Binary) how would we divide it by 3(Binary). > Using either a Shifter or MAC(Multiply Accumulate). > > Thanks in Advance, > Rohini.
Assuming that you have a fast fixed point multiply and shift: Multiply by 32768/3, shift right by 15. Y = (X * 10923) >> 15; -- Hershel
Raymond Toy wrote:
(snip)

> It is, in fact, possible to find a "reciprocal" such that when you > multiply it by X, you get the exact (scaled) quotient of X/3, from > which an exact remainder can also be calculated. Don't know if that's > what is wanted or some good enough approximation to X/3.
It might not be easy, though. The IBM S/360 specifies truncation for floating point divide. The 360/91 uses an iterative algorithm that gives the rounded quotient, instead of the architecture specified truncated quotient. I presume it was easier in terms of logic and/or speed. -- glen