Square root in C using Newton-Raphson method

后端 未结 4 682
一向
一向 2021-01-16 10:08

In the following code, I want to replace the termination condition to: if the ratio of guess square and x is close to 1, while loop should terminate. I tried various express

4条回答
  •  深忆病人
    2021-01-16 10:57

    hit the answer: while statement should be like this:

     while  ( absoluteValue((guess * guess) / x  - 1.0) >= 0.0001 ) 
    

提交回复
热议问题