sqrt

fun sqrt(value: KBigDecimal, scale: Int = 10): KBigDecimal

Calculates the square root of a KBigDecimal using Newton-Raphson iteration. The initial estimate is derived from the decimal exponent so inputs outside the Double range remain in the right order of magnitude.

Return

The square root of the input value with the specified precision

Parameters

value

The KBigDecimal to calculate the square root of

scale

The number of decimal places in the result (default: 10)

Throws

ArithmeticException

if the value is negative or the iteration does not converge

IllegalArgumentException

if scale is negative or too large