Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import compute.Task;
- import java.io.Serializable;
- import java.math.BigDecimal;
- public class Silnia implements Task<BigDecimal>, Serializable
- {
- /** constants used in pi computation */
- private static final BigDecimal FOUR =
- BigDecimal.valueOf(4);
- /** rounding mode to use during pi computation */
- private static final int roundingMode =
- BigDecimal.ROUND_HALF_EVEN;
- /** digits of precision after the decimal point */
- private final int digits;
- /**
- * Construct a task to calculate pi to the specified
- * precision.
- */
- public Silnia(int digits)
- {
- this.digits = digits;
- }
- /**
- * Calculate pi.
- */
- public BigDecimal SilniaBig(BigDecimal a) {
- BigDecimal wynik = BigDecimal.ONE;
- for (int j = 2; j <=a.intValue(); j++) {
- wynik = wynik.multiply(BigDecimal.valueOf(j));
- }
- return wynik;
- }
- }
Add Comment
Please, Sign In to add comment