Campbell Ritchie wrote:You have written that loop wrongly; you can remove about ⅝ of it.Why are you asking for doubles in your square root method and taking ints from the keyboard? I would suggest you change the loop to do…while (num >= 0);
Don't start method names with CapitalLetters.
Out on HF and heard nobody, but didn't call CQ? Nobody heard you either. 73 de N7GH
Les Morgan wrote:You're approximation algorithm is flawed:
(N*N)/(2N) -> infinity. Your method is divergent.
jin Otanashi wrote:
Les Morgan wrote:You're approximation algorithm is flawed:
(N*N)/(2N) -> infinity. Your method is divergent.
you mean i need to do like (high * low )/2 ?
Out on HF and heard nobody, but didn't call CQ? Nobody heard you either. 73 de N7GH
Les Morgan wrote:
jin Otanashi wrote:
Les Morgan wrote:You're approximation algorithm is flawed:
(N*N)/(2N) -> infinity. Your method is divergent.
you mean i need to do like (high * low )/2 ?
You need to have an algo that converges to your approximation, the formula you have does not.
I did a quick and dirty little algo and this worked for me if I don't be too crazy with it--just put the target number in for the guess and it brings thing around to a good approximation:
dTarget is the number you want the squareroot
dTrial is the guess (put dTarget in here for a start)
dTolerance is the error you are willing to accept (0.0001 seems to work well)
Carey Brown wrote:Why are you multiplying by one?
Campbell Ritchie wrote:Please show us what you achieved in the end.
Consider Paul's rocket mass heater. |