Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
integer square root algorithm
#1
Here's a little exercize. Make the most efficient algorithm that returns the integer closest to, but not exceeding the square root of another integer. This is to be done without using floating point conversions.

1->1
2->1
3->1
4->2
5->2
6->2
7->2
8->2
9->3
...
1023->31
1024->32
1025->32
...
etc.

I was working on this for a program that needed to calculate lots of approximate square roots and converting to floats is unacceptable. In other words, doing something like:
int(sqr(99))
is not acceptable.

I'm doing the work in c++, but QB should allow us to find the fastest alg. Anyone want to work on this one?
Reply


Messages In This Thread
integer square root algorithm - by Mango - 12-31-2004, 09:26 AM
integer square root algorithm - by Mango - 12-31-2004, 12:24 PM
integer square root algorithm - by Z!re - 12-31-2004, 12:41 PM
integer square root algorithm - by Mango - 12-31-2004, 07:22 PM
integer square root algorithm - by Mango - 12-31-2004, 07:36 PM
integer square root algorithm - by Mango - 01-01-2005, 11:38 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)