< prev index next >
src/java.base/share/classes/java/math/BigDecimal.java
Print this page
*** 1991,2000 ****
--- 1991,2034 ----
result[0] = lhs.divideToIntegralValue(divisor, mc);
result[1] = lhs.subtract(result[0].multiply(divisor));
return result;
}
+
+ /**
+ * Returns an approximation to the square root of {@code this}
+ * with rounding according to the context settings.
+ *
+ * <p>The preferred scale of the returned result is equal to
+ * {@code floor(this.scale()/2.0)}. 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 {@link
+ * RoundingMode#HALF_UP HALF_UP}, {@link RoundingMode#HALF_DOWN
+ * HALF_DOWN}, or {@link RoundingMode#HALF_EVEN HALF_EVEN}, the
+ * result is within one half an ulp of the exact decimal value.
+ *
+ * <p>Special case:
+ * <ul>
+ * <li> The square root of {@code ZERO} is {@code ZERO}
+ * </ul>
+ *
+ * @param mc the context to use.
+ * @return the square root of {@code this}.
+ * @throws ArithmeticException if {@code this} is less than zero.
+ * @throws ArithmeticException if an exact result is requested
+ * ({@code mc.getPrecision()==0}) and there is no finite decimal
+ * expansion of the exact result
+ * @throws ArithmeticException if
+ * {@code (mc.getRoundingMode()==RoundingMode.UNNECESSARY}) and
+ * the exact result cannot fit in {@code mc.getPrecision()}
+ * digits.
+ * @since 9
+ */
+ BigDecimal sqrt(MathContext mc) {
+ return ZERO; // Just the specification for now.
+ }
+
/**
* Returns a {@code BigDecimal} whose value is
* <code>(this<sup>n</sup>)</code>, The power is computed exactly, to
* unlimited precision.
*
< prev index next >