Levels Tought:
Elementary,Middle School,High School,College,University,PHD
Teaching Since: | Apr 2017 |
Last Sign in: | 10 Weeks Ago, 4 Days Ago |
Questions Answered: | 4870 |
Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Write an assembly code subroutine to approximate the square root of an argument using the bisection... Each and every maths is done with integers, so the resulting square root will also be an integer.
pseudocode is as follows:
Approximate square root with bisection method INPUT
The argument x, endpoint values a, b, such that a < b
OUTPUT: value which differs from sqrt(x) by less than 1
done = 0
a = 0
b = square root of largest possible argument (For example2^16). c = -1
do
{
c_old <- c
c <- (a+b)/2
if (c*c == x) {
done = 1 }
else if (c*c < x)
{ a <- c }
else { b <- c
} } while (!done) && (c != c_old) return c
-----------