Division and Multiply of Binary #'s
Chris Fanning email (remove spam text)
> How do you Divide two binary numbers
> "long division"
> Say you have 1234 / 6. Long division says:
> 6 / 1234 2
> 03 0
> 34 5
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 8-bits.
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.. :)
In reply to: <CMM.firstname.lastname@example.org> from William Chops Westfield at "Oct 29, 1999 11:35: 7 am"
See also: www.piclist.com/techref/method/math.htm?key=multiply
You must be a member of the
piclist mailing list
(not only a www.piclist.com member) to post to the