whereas teh mothod I suggested does find 0 < x < 1 for all positive real numbers.
whereas teh mothod I suggested does find 0 < x < 1 for all positive real numbers.
Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.
By the way, ((U - L)/2) is the same thing as (U + L) / 2.
Or, better yet, (U + L) >> 1.
EDIT:
didn't realize they were doubles
Last edited by rudyman; 07-30-2008 at 04:44 PM.
Are you sure bitshifting works with doubles, though?
I might be wrong.
Quoted more than 1000 times (I hope).Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
You're trying to calculate the square root by using the Newton-Raphson method by the looks of it. The problem is that you got the formula wrong. Go back and look it up again!
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
Heck I see; you're right. That's horrible!
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
If you want to get really fancy with square roots, here's a link describing how to calculate square roots by hand:
http://www.geocities.com/cnowlen/Cat...Squareroot.htm
I once implemented this in a class that does arithmetic on arbitrary length integers. Granted, it wasn't as efficient as the gmp implementation, but it's still cool to learn how to do.