summaryrefslogtreecommitdiff
path: root/src/test/java/com/seaofnodes/simple/spill/Chapter20Test-testNewtonFloat.smp
blob: fd76478fa864deac6cf996a03522c334609836ef (plain)
1
2
3
4
5
6
7
8
9
10
11
// Newtons approximation to the square root
val _sqrt = { flt x ->
    flt guess = x;
    while( 1 ) {
        flt next = (x/guess + guess)/2;
        if( next == guess ) return guess;
        guess = next;
    }
};
flt farg = arg;
return _sqrt(farg) + _sqrt(farg+2.0);