'put this in main:
Dim jo as JavaObject
jo.initializeContext
Dim scale As Int = 200 ' scale to fit
dim somebigdecimal as string = "4" ' put your bigdecimal here
Dim bdstring As String = jo.RunMethod("bdsqrt", Array(somebigdecimal,scale))
Log(bdstring)
'=========================================================
'tack this onto your project:
#if Java
import java.lang.Math;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;
import java.math.RoundingMode;
public static String bdsqrt(String strparam, int SCALE) {
BigDecimal A = new BigDecimal( strparam );
final BigDecimal TWO = BigDecimal.valueOf(2);
BigDecimal x0 = new BigDecimal("0");
BigDecimal x1 = new BigDecimal(Math.sqrt(A.doubleValue()));
while (!x0.equals(x1)) {
x0 = x1;
x1 = A.divide(x0, SCALE, 4);
x1 = x1.add(x0);
x1 = x1.divide(TWO, SCALE, 4);
}
return x1.toPlainString();
}
#End If