Guest User

Untitled

a guest
May 20th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.91 KB | None | 0 0
  1.  
  2.  
  3. import compute.Task;
  4. import java.io.Serializable;
  5. import java.math.BigDecimal;
  6.  
  7. public class Silnia implements Task<BigDecimal>, Serializable
  8. {
  9.  
  10.    
  11.  
  12.     /** constants used in pi computation */
  13.     private static final BigDecimal FOUR =
  14.         BigDecimal.valueOf(4);
  15.  
  16.     /** rounding mode to use during pi computation */
  17.     private static final int roundingMode =
  18.         BigDecimal.ROUND_HALF_EVEN;
  19.  
  20.     /** digits of precision after the decimal point */
  21.     private final int digits;
  22.  
  23.     /**
  24.      * Construct a task to calculate pi to the specified
  25.      * precision.
  26.      */
  27.         public Silnia(int digits)
  28.     {
  29.         this.digits = digits;
  30.     }
  31.  
  32.     /**
  33.      * Calculate pi.
  34.      */
  35.  
  36.    
  37. public BigDecimal SilniaBig(BigDecimal a) {
  38.        
  39.         BigDecimal wynik = BigDecimal.ONE;
  40.  
  41.         for (int j = 2; j <=a.intValue(); j++) {
  42.             wynik = wynik.multiply(BigDecimal.valueOf(j));
  43.         }
  44.  
  45.         return wynik;
  46.     }
  47. }
Add Comment
Please, Sign In to add comment