sqrt

fun sqrt(mc: MathContext = MathContext()): BigDecimal

Returns an approximation to the square root of this with rounding according to the context settings.

The preferred _scale of the returned result is equal to this._scale()/2. The value of the returned result is always within one ulp of the exact decimal value for the _precision in question. If the rounding mode is , HALF_DOWN, or HALF_EVEN, the result is within one half an ulp of the exact decimal value.

Special case:

  • The square root of a number numerically equal to ZERO is numerically equal to ZERO with a preferred _scale according to the general rule above. In particular, for ZERO, ZERO.sqrt(mc).equals(ZERO) is true with any MathContext as an argument.

Return

the square root of this.

Since

9

See also

Parameters

mc

the context to use.

Throws

if (mc.getRoundingMode()==RoundingMode.UNNECESSARY) and the exact result cannot fit in mc.getPrecision() digits.