Package java.math

Examples of java.math.BigInteger.pow()


        return ConstantsSimulation.DEFAULT_MASTER_SCHEDULER_ID + "-primePolynome";
    }
   
    public static void main(String[] args) {
        BigInteger num = new BigInteger("10");
        num = num.pow(2000);
        num = num.multiply(new BigInteger("6"));
        num = num.subtract(new BigInteger("1"));
        System.out.println(num);
        System.out.println(num.isProbablePrime(Integer.MAX_VALUE));
    }
View Full Code Here


    public NodeValue exec(NodeValue v) {
        switch (XSDFuncOp.classifyNumeric("cube", v))
        {
            case OP_INTEGER:
                BigInteger i = v.getInteger();
                return NodeValue.makeInteger( i.pow(3) );
            case OP_DECIMAL:
                double dec = v.getDecimal().doubleValue() ;
                return NodeValue.makeDecimal( Math.pow(dec, 3d)) ;
            case OP_FLOAT:
                // TODO Should squaring a float keep it a float?
View Full Code Here

    public NodeValue exec(NodeValue v) {
        switch (XSDFuncOp.classifyNumeric("sq", v))
        {
            case OP_INTEGER:
                BigInteger i = v.getInteger();
                return NodeValue.makeInteger( i.pow(2) );
            case OP_DECIMAL:
                double dec = v.getDecimal().doubleValue() ;
                return NodeValue.makeDecimal( Math.pow(dec, 2d)) ;
            case OP_FLOAT:
                // TODO Should squaring a float keep it a float?
View Full Code Here

    public NodeValue exec(NodeValue v1, NodeValue v2) {
        switch (XSDFuncOp.classifyNumeric("pow", v1))
        {
            case OP_INTEGER:
                BigInteger i = v1.getInteger();
                return NodeValue.makeInteger( i.pow(v2.getInteger().intValue()) );
            case OP_DECIMAL:
                double dec = v1.getDecimal().doubleValue() ;
                return NodeValue.makeDecimal( Math.pow(dec, v2.getDouble())) ;
            case OP_FLOAT:
                // TODO Should raising a float to a power keep it a float?
View Full Code Here

                        */
                        for(int primindx=0 ; primindx < pows.size() ; primindx++)
                        {
                                int ex= pows.elementAt(primindx).intValue() ;
                                final BigInteger p = primes.at(primindx) ;
                                n = n.multiply( p.pow(ex) ) ;
                                primeexp.add(new Integer(p.intValue()) ) ;
                                primeexp.add(new Integer(ex) ) ;
                        }
                }
                else
View Full Code Here

                {
                        pows.primeexp.add( primeexp.elementAt(i)) ;
                        pows.primeexp.add( primeexp.elementAt(i+1)) ;
                        BigInteger p = new BigInteger( primeexp.elementAt(i).toString() ) ;
                        int ex = primeexp.elementAt(i+1).intValue() ;
                        pows.n = pows.n.multiply( p.pow(ex) ) ;
                }
                return pows ;
        } /* Ifactor.dropPrime */

        /** Test whether this is a square of an integer (perfect square).
View Full Code Here

                return tpow.integer[i];
            }
        }

        BigInteger bi=_getBigInt_(i,cache);
        tpow.integer[i]=bi.pow(npow);
        tpow.power[i]=npow;
        return tpow.integer[i];
    }
   
    /*
 
View Full Code Here

    public Element mul(BigInteger num) {
      Element now = this;
      int count = 0;
      BigInteger two = new BigInteger("2");
      while (two.pow(count).compareTo(num) <= 0) {
        count++;
      }
      Element[] pows = new Element[count];
      pows[0] = now;
      for (int i = 1; i < pows.length; i++) {
View Full Code Here

      return BigInteger.valueOf(LongMath.sqrt(x.longValue(), mode));
    }
    BigInteger sqrtFloor = sqrtFloor(x);
    switch (mode) {
      case UNNECESSARY:
        checkRoundingUnnecessary(sqrtFloor.pow(2).equals(x)); // fall through
      case FLOOR:
      case DOWN:
        return sqrtFloor;
      case CEILING:
      case UP:
View Full Code Here

      case FLOOR:
      case DOWN:
        return sqrtFloor;
      case CEILING:
      case UP:
        return sqrtFloor.pow(2).equals(x) ? sqrtFloor : sqrtFloor.add(BigInteger.ONE);
      case HALF_DOWN:
      case HALF_UP:
      case HALF_EVEN:
        BigInteger halfSquare = sqrtFloor.pow(2).add(sqrtFloor);
        /*
 
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.