Motherboard Forums


Reply
Thread Tools Display Modes

Re: Integer Square Root Algorithm for Processor with MUL, DIV

 
 
Didi
Guest
Posts: n/a
 
      05-01-2008, 07:30 PM
David T. Ashley wrote:
> ...
> The algorithm that comes to mind is just to do a binary search by squaring
> potential solutions and comparing them to the quantity whose square root is
> to be extracted.
>
> For example, if the sum of the squares is 16 bits or less, and since the
> processor has a 8 x 8 = 16 MUL instruction, it should be possible to iterate
> to the solution in no more than 16 square/compare cycles.
>


Actually you can do this in 8 multiplies. This is how I usually
implement
square root - I have probably reinvented it some 15+ years ago for
myself.
You just start with $80, square and compare to the number you want
the root of, and do successive approximation down to bit 0 (i.e.
second time
with $40+result so far, then $20 etc.).

Dimiter

------------------------------------------------------
Dimiter Popoff Transgalactic Instruments

http://www.tgi-sci.com
------------------------------------------------------
http://www.flickr.com/photos/didi_tg...7600228621276/

Original message: http://groups.google.com/group/comp....6?dmode=source
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT. The time now is 05:32 PM.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44