No exact or substring matches. trying for part
PICList
Thread
'Division and Multiply of Binary #'s'
1999\10\29@134329
by
John Considine
I am half embarrassed to ask this question, but I do not have my old
Computer Architecture book and can't remember how to do it.
How do you Divide two binary numbers and How do you Multiply to binary
numbers.
1999\10\29@143716
by
William Chops Westfield
How do you Divide two binary numbers
"long division"
Say you have 1234 / 6. Long division says:
_______
6 / 1234 2
12
03 0
00
34 5
30
4
So you get 205 (with 4 as a remainder.) In binary, all the "thinkwork"
(12/6, etc) is just a compare with a 0 or 1 result, and the reset is
bit shifting and subtracting.
___________
101 / 101011 0 (43/5)
0
1
101
00 0
001 0
0011 0

11 (8, remainder 3)
How do you Multiply to binary numbers.
"long multiplication"
456
x 123

1368 (3*456)
0912 (2*456*10)
0456 (1*456*100)

56088
Again, once you're in binary, this becomes all bit tests, shifts, and adds.
1101 (13)
x 101 ( 5)

1101
0000
1101

1000001 (65)
BillW
1999\10\29@221953
by
hris Fanning
> How do you Divide two binary numbers
>
> "long division"
>
> Say you have 1234 / 6. Long division says:
>
> _______
> 6 / 1234 2
> 12
> 03 0
> 00
> 34 5
> 30
> 4
Yes, this works. But how about for negative numbers?
There's a slow algorithm in text books that's very applicable here. And
when I say slow, I mean it's 1 "operation" per bit. (You can do better.)
It's just about as much work as the algorithm described above and works
for all values. Perfect for a PIC which has adds and subtracts with the
exception that the registers are only 8bits.
I used it for an IEEE 754 divider in Verilog. If anyone wants I'll
dig up the references. It came from a horribly well known book which
I can't remember the title of at the moment.
It'd be really easy for me to replace a $1.50 PIC with a $90 FPGA.. :)
Chris
1999\10\30@035100
by
Keith Causey

In order to use this algorithm for signed numbers save the xored "most
significant bit" of each operand; get the absolute value of each operand;
perform the multiplication or division; and finally complement the result if
the xored most significant bit is set.
{Quote hidden}> > How do you Divide two binary numbers
> >
> > "long division"
> >
> > Say you have 1234 / 6. Long division says:
> >
> > _______
> > 6 / 1234 2
> > 12
> > 03 0
> > 00
> > 34 5
> > 30
> > 4
>
> Yes, this works. But how about for negative numbers?
>
> There's a slow algorithm in text books that's very applicable here. And
> when I say slow, I mean it's 1 "operation" per bit. (You can do better.)
> It's just about as much work as the algorithm described above and works
> for all values. Perfect for a PIC which has adds and subtracts with the
> exception that the registers are only 8bits.
>
> I used it for an IEEE 754 divider in Verilog. If anyone wants I'll
> dig up the references. It came from a horribly well known book which
> I can't remember the title of at the moment.
>
> It'd be really easy for me to replace a $1.50 PIC with a $90 FPGA.. :)
>
> Chris
More... (looser matching)
 Last day of these posts
 In 1999
, 2000 only
 Today
 New search...