Package java.math

Examples of java.math.BigInteger.shiftLeft()


            if ( val.longValue() > EncodingUtil.getMaxValue(fd.getWidth()).longValue()) {
                throw new IllegalArgumentException("value to large for field width: " + val);           
            }
           
            encoded = encoded.or(val.shiftLeft(fd.getOffset()));
        }
       
        return encoded;
    }
   
View Full Code Here


        BigInteger big = BigInteger.ZERO;
        for (int i = 0; i < str.length(); i++)
        {
            int charpos = 16 * (sigchars - (i + 1));
            BigInteger charbig = BigInteger.valueOf(str.charAt(i) & 0xFFFF);
            big = big.or(charbig.shiftLeft(charpos));
        }
        return big;
    }

    /**
 
View Full Code Here

        for (int i=0; i<100; i++) {
            BigInteger x = fetchNumber(order1);
            int n = Math.abs(rnd.nextInt()%200);

            if (!x.shiftLeft(n).equals
                (x.multiply(BigInteger.valueOf(2L).pow(n))))
                failCount1++;

            BigInteger y[] =x.divideAndRemainder(BigInteger.valueOf(2L).pow(n));
            BigInteger z = (x.signum()<0 && y[1].signum()!=0
View Full Code Here

        BigInteger big = BigInteger.ZERO;
        for (int i = 0; i < str.length(); i++)
        {
            int charpos = 16 * (sigchars - (i + 1));
            BigInteger charbig = BigInteger.valueOf(str.charAt(i) & 0xFFFF);
            big = big.or(charbig.shiftLeft(charpos));
        }
        return big;
    }

    /**
 
View Full Code Here

    int biasedExp = (int) (rawBits >> 52);
    if (biasedExp == 0) {
      // sub-normal numbers
      BigInteger frac = BigInteger.valueOf(rawBits).and(BI_FRAC_MASK);
      int expAdj = 64 - frac.bitLength();
      _significand = frac.shiftLeft(expAdj);
      _binaryExponent = (biasedExp & 0x07FF) - 1023 - expAdj;
    } else {
      BigInteger frac = getFrac(rawBits);
      _significand = frac;
      _binaryExponent = (biasedExp & 0x07FF) - 1023;
View Full Code Here

    while (frac.bitLength() + orig.getBinaryExponent() < 200) {
      frac = frac.multiply(BIG_POW_10);
    }
    int binaryExp = orig.getBinaryExponent() - orig.getSignificand().bitLength();

    String origDigs = frac.shiftLeft(binaryExp+1).toString(10);

    if (!origDigs.startsWith(sigDigs)) {
      throw new AssertionFailedError("Expected '" + origDigs + "' but got '" + sigDigs + "'.");
    }
View Full Code Here

        BigInteger big = BigInteger.ZERO;
        for (int i = 0; i < str.length(); i++)
        {
            int charpos = 16 * (sigchars - (i + 1));
            BigInteger charbig = BigInteger.valueOf(str.charAt(i) & 0xFFFF);
            big = big.or(charbig.shiftLeft(charpos));
        }
        return big;
    }

    /**
 
View Full Code Here

  private static int hazelnuts(BigInteger n) {
    int h = 0;
    BigInteger x = BigInteger.ZERO, y = BigInteger.ZERO;

    while ((y = x.shiftLeft(1).add(BigInteger.ONE)).compareTo(n) < 0) {
      x = y;
      h++;
    }
    y = n.subtract(x);
    while (y.compareTo(BigInteger.ZERO) > 0) {
View Full Code Here

        BigInteger big = BigInteger.ZERO;
        for (int i = 0; i < str.length(); i++)
        {
            int charpos = 16 * (sigchars - (i + 1));
            BigInteger charbig = BigInteger.valueOf(str.charAt(i) & 0xFFFF);
            big = big.or(charbig.shiftLeft(charpos));
        }
        return big;
    }

    /**
 
View Full Code Here

        TA = initPosArray();
        TB = new int[S];
        while (rounds.compareTo(BigInteger.ZERO) > 0) {
            if (rounds.testBit(0))
                addToTotals();
            roundsToUse = roundsToUse.shiftLeft(1);
            rounds = rounds.shiftRight(1);
            nextCalc();
        }
        int remTurns = N.mod(GS).intValue();
        countWrites(remTurns);
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.