Hi,
I have the need in a microcontroller application to calculate floor(sqrt(x)) where x is approximately in the range of 2^32 - 2^64.
What are the algorithms I should look at?
These small microcontrollers are characterized by having a 8-bit times 8-bit to give 16-bit result integer unsigned multiply instruction, and a similar
16/8 division instruction to give a quotient and a remainder. Mulitplications of larger integers have to be done by multiplying the bytes and adding.I'm aware of these algorithms:
a)Adding consecutive odd integers and counting how many you have to add, i.e. 1 + 3 = 4, 4 + 5 = 9, 9 + 7 = 16, 16 + 9 = 25, etc.
b)Trial squaring, testing setting each bit to "1", i.e.
c)Another method that seems to work (don't know the name of it), here is source code:
What other options should I investigate?
Thanks, Datesfat