Makes this number an {@code n}-int number all of whose bits are ones.
Used by Burnikel-Ziegler division.
@param n number of ints in the {@code value} array
@return a number equal to {@code ((1<<(32*n)))-1}
330961
private void ones(int n) {
        if (n > value.length)
            value = new int[n];
        Arrays.fill(value, -1);
        offset = 0;
        intLen = n;
    }
66420
private static BigInteger getFactorial (int n) {
		BigInteger fact = BigInteger.ONE;
		for (int i = n; i > 1; i--) {
			fact = fact.multiply (new BigInteger (Integer.toString (i)));
		}
		return fact;
	}
1126481
public static byte[] long2buff(long n) {
        byte[] bs;

        bs = new byte[8];
        bs[0] = (byte) ((n >> 56) & 0xFF);
        bs[1] = (byte) ((n >> 48) & 0xFF);
        bs[2] = (byte) ((n >> 40) & 0xFF);
        bs[3] = (byte) ((n >> 32) & 0xFF);
        bs[4] = (byte) ((n >> 24) & 0xFF);
        bs[5] = (byte) ((n >> 16) & 0xFF);
        bs[6] = (byte) ((n >> 8) & 0xFF);
        bs[7] = (byte) (n & 0xFF);

        return bs;
    }
514780
private static boolean isInteger( Number n ) {
      if( n instanceof Integer ){
         return true;
      }
      try{
         Integer.parseInt( String.valueOf( n ) );
         return true;
      }catch( NumberFormatException e ){
         return false;
      }
   }
1027228
public static long factorial(int n) {
    long nFac = 1;
    for(long i = n; i > 0; i--) {
      nFac *= i;
    }
    return nFac;
  }
288334
public JBBPOut Bits(final JBBPBitNumber numberOfBits, final int value) throws IOException {
    assertNotEnded();
    JBBPUtils.assertNotNull(numberOfBits, "Number of bits must not be null");
    if (this.processCommands) {
      _writeBits(numberOfBits, value);
    }
    return this;
  }
250884
public static void setInt(final byte[] b, final int n, final int offset) {
        b[offset + 0] = (byte) (n >>> 24);
        b[offset + 1] = (byte) (n >>> 16);
        b[offset + 2] = (byte) (n >>> 8);
        b[offset + 3] = (byte) (n >>> 0);
    }
1026516
public static double I(int n, double x) {
        if (n < 0)
            throw new IllegalArgumentException("the variable n out of range.");
        else if (n == 0)
            return I0(x);
        else if (n == 1)
            return I(x);

        if (x == 0.0)
            return 0.0;

        double ACC = 40.0;
        double BIGNO = 1.0e+10;
        double BIGNI = 1.0e-10;

        double tox = 2.0 / Math.abs(x);
        double bip = 0, ans = 0.0;
        double bi = 1.0;

        for (int j = 2 * (n + (int) Math.sqrt(ACC * n)); j > 0; j--) {
            double bim = bip + j * tox * bi;
            bip = bi;
            bi = bim;

            if (Math.abs(bi) > BIGNO) {
                ans *= BIGNI;
                bi *= BIGNI;
                bip *= BIGNI;
            }

            if (j == n)
                ans = bip;
        }

        ans *= I0(x) / bi;
        return x < 0.0 && n % 2 == 1 ? -ans : ans;
    }
1197532
public long readNBit(int n) throws IOException {
        if (n > 64)
            throw new IllegalArgumentException("Can not readByte more then 64 bit");

        long val = 0;

        for (int i = 0; i < n; i++) {
            val <<= 1;
            val |= read1Bit();
        }

        return val;
    }
675982
private static boolean isBigDecimal( Number n ) {
      if( n instanceof BigDecimal ){
         return true;
      }
      try{
         new BigDecimal( String.valueOf( n ) );
         return true;
      }catch( NumberFormatException e ){
         return false;
      }
   }
453368
public int decodeNBitUnsignedInteger(int n) throws IOException {
		assert (n >= 0);

		int bitsRead = 0;
		int result = 0;

		while (bitsRead < n) {
			// result = (result << 8) | is.read();
			result += (decode() << bitsRead);
			bitsRead += 8;
		}
		return result;
	}
706284
public void encodeUnsignedInteger(int n) throws IOException {
		if (n < 0) {
			throw new UnsupportedOperationException();
		}

		if (n < 128) {
			// write byte as is
			encode(n);
		} else {
			final int n7BitBlocks = MethodsBag.numberOf7BitBlocksToRepresent(n);

			switch (n7BitBlocks) {
			case 5:
				encode(128 | n);
				n = n >>> 7;
			case 4:
				encode(128 | n);
				n = n >>> 7;
			case 3:
				encode(128 | n);
				n = n >>> 7;
			case 2:
				encode(128 | n);
				n = n >>> 7;
			case 1:
				// 0 .. 7 (last byte)
				encode(0 | n);
			}
		}
	}
806929
public PackedDecimal movePointRight(int n) {
        BigDecimal result = toBigDecimal().movePointRight(n);
        return PackedDecimal.valueOf(result);
    }
883124
public int hgetbits(int N)
   {
   	 totbit += N;
	 
	 int val = 0;
	 
	 int pos = buf_byte_idx;
	 if (pos+N < BUFSIZE)
	 {
		while (N-- > 0)
		{
			val <<= 1;
			val |= ((buf[pos++]!=0) ? 1 : 0);		 
		}
	}
	 else
	 {	 
		 while (N-- > 0)
		{
			 val <<= 1;			 
			 val |= ((buf[pos]!=0) ? 1 : 0);
			 pos = (pos+1) & BUFSIZE_MASK;
		}		 
	 }	
	 buf_byte_idx = pos;
	 return val;
   }
315615
public int nextSetBit(final int i) {
    int x = i >> 6;
    long w = bitmap[x];
    w >>>= i;
    if (w != 0) {
      return i + numberOfTrailingZeros(w);
    }
    for (++x; x < bitmap.length; ++x) {
      if (bitmap[x] != 0) {
        return x * 64 + numberOfTrailingZeros(bitmap[x]);
      }
    }
    return -1;
  }
726095
public int readBits(int n) throws IOException {
		assert (n > 0);
		int result;

		if (n <= capacity) {
			// buffer already holds all necessary bits
			result = (buffer >> (capacity -= n))
					& (0xff >> (BUFFER_CAPACITY - n));
		} else if (capacity == 0 && n == BUFFER_CAPACITY) {
			// possible to read direct byte, nothing else to do
			result = readDirectByte();
		} else {
			// get as many bits from buffer as possible
			result = buffer & (0xff >> (BUFFER_CAPACITY - capacity));
			n -= capacity;
			capacity = 0;

			// possibly read whole bytes
			while (n > 7) {
				if (capacity == 0) {
					readBuffer();
				}
				result = (result << BUFFER_CAPACITY) | buffer;
				n -= BUFFER_CAPACITY;
				capacity = 0;
			}

			// read the rest of the bits
			if (n > 0) {
				if (capacity == 0) {
					readBuffer();
				}
				result = (result << n)
						| (buffer >> (capacity = (BUFFER_CAPACITY - n)));
			}
		}

		return result;
	}
1075047
@Override
    public int nextInt(int n) {
        if (n <= 0) {
            throw new IllegalArgumentException("n must be positive");
        }

        // the special treatment of powers of 2 as in Random.nextInt(int) shouldn't be necessary
        int bits, val;
        do {
            bits = nextInt() >>> 1;
            val = bits % n;
        } while (bits - val + (n - 1) < 0);
        return val;
    }