Java 递归平方根,公差为.1关

Java 递归平方根,公差为.1关,java,recursion,Java,Recursion,我在用递归计算平方根,我似乎不明白为什么tol会出现.1short public static float sqrRootRec(float number, float approx, float tol) { if((Math.abs((Math.pow(approx,2) - number))<= tol*number)) { return approx; } else return sqrRootRec(number, (approx*a

我在用递归计算平方根,我似乎不明白为什么
tol
会出现
.1
short

public static float sqrRootRec(float number, float approx, float tol) {

    if((Math.abs((Math.pow(approx,2) - number))<= tol*number)) {
       return approx;
    } else
       return sqrRootRec(number, (approx*approx + number)/(approx + approx),tol);
}
public static float sqrRootRec(浮点数、浮点数近似值、浮点数tol){

如果((数学绝对值((数学功率(约2)-数量))返回并给帮助过你的人打分-否则没有帮助我无法两次投票给gpasch的评论,所以这里有一条评论。不要滥用该网站。你有很多问题没有被接受的答案,阿尔比特的答案很好。请对那些投入时间帮助你的人表示尊重。@gpasch我确实点击了up arrow对于他们两人,我也说了谢谢。@VinceEmigh我是这个网站的新手。他们给了我帮助,我给了他们两人更高的票数,但他们说我需要15个声望点才能出现。我不知道如何回答他们另一个问题,所以我提出了一个新的话题。对不起,这是真的。你现在不能投票,但你可以接受正确的答案