18.BigInteger
 BigIntegerクラスはNumberクラスのサブクラスで、long型の数値を扱う際に便利な機能を備える。 

import java.math.BigInteger

メンバー変数

static
BigInteger

ZERO
    BigInteger型の0を表す。

static
BigInteger

ONE
    BigInteger型の1を表す。
コンストラクタ
BigInteger(byte[] val)
      2の補数2進表現を含むバイト配列をBigIntegerに変換する。valの配列の大きさが0の場合はNumberFormatExceptionが投げられる。
BigInteger(String val)
      "-4096"のように符号と10進数の文字列表現をBigIntegerに変換する。valの値が不正の場合はNumberFormatExceptionが投げられる。
BigInteger(String val,int radix)
      符号とradix進数の文字列表現をBigIntegerに変換する。radixが10の場合は一つ上のコンストラクタと同じになる。valの値が不正の場合、radixが2〜36以外の場合はNumberFormatExceptionが投げられる。
BigInteger(int numBits,Random rnd)
      0〜(2numBits-1) の範囲にある一様分布の乱数を返す。numBitsが負数の場合はIllegalArgumentExceptionが投げられる。
 
メソッド
static
BigInteger
valueOf(long val)
      valをBigInteterに変換する。
BigInteger add(BigInteger val)
      自分とvalの値を加えたBigIntegerを返す。
BigInteger subtract(BigInteger val)
      
自分からvalを引いたBigIntegerを返す。
BigInteger negative()
      -thisを返す。
BigInteger multiply(BigInteger val)
      this * valを返す。
BigInteger divide(BigInteger val)
      this/valを返す。valが0の場合はArithmeticExceptionが投げられる。
BigInteger remainder(BigInteger val)
      this % val(0もしくは正数)を返す。valが0の場合はArithmenticExceptionが投げられる。
BigInteger divideAndRemainder(BigInteger val)
      this/valとthis % val(0もしくは正数)とからなる要素2のBigInteger配列を返す。valが0の場合はArithmeticExceptionが投げられる。
BigInteger mod(BigInteger val)
      this mod val(負数になる可能性がある)を返す。
BigInteger abs()
      
絶対値を返す。
BigInteger pow(int exponent)
      thisexponentを返します。
      exponentが負数の場合はArithmeticExceptionが投げらる。
BigInteger modPow(BigInteger exponent, BigInteger m)
      thisexponent mod m(負数になる可能性がある)を返す。valが0の場合はArithmeticExceptionが投げらる。
BigInteger gcd(BigInteger val)
      thisの絶対値とvalの絶対値の最大公約数を求める。
double doubleValue()
      double型に変換します。絶対値が大きくてdouble型に変換できない場合は、正の無限大Double.POSITIVE_INFINITYもしくは、負の無限大Double.NEGATIVE_INFINITYが返される。
int floatValue()
      float型に変換する。絶対値が大きくてfloat型に変換できない場合は、正の無限大Float.POSITIVE_INFINITYもしくは、負の無限大Float.NEGATIVE_INFINITYが返される。
int intValue()
      int型に変換する。絶対値が大きくてint型に変換できない場合は、下位32bitのみが保持される。
long longValue()
      long型に変換する。絶対値が大きくてlong型に変換できない場合は、下位64bitのみが保持される。
byte[] toByteArray()
      このBigIntegerの2の補数表現を含むバイト配列を返します。バイト配列は「ビッグエンディアン」の並びになる。
String toString()
      このBigIntegerを10進数で文字列表現に変換する。
String toString(int radix)
      このBigIntegerをradix進数で文字列表現に変換する。
boolean equals(Object o)
      oがBigIntegerクラスで、thisと同じ値である場合にtrueが返される。
int compareTo(BigInteger val)
      valと比較をし、this<valの場合は-1、this=valの場合は0、this>valの場合は+1が返される。
BigInteger max(BigInteger val)
      thisとvalの大きい方が返される。
BigInteger min(BigInteger val)
      thisとvalの小さい方が返される。
BigInteger and(BigInteger val)
      自分とvalの論理積をとる。(this & val)
BigInteger or(BigInteger val)
      自分とvalの論理和をとる。(this | val)
BigInteger xor(BigInteger val)
      自分とvalの排他的論理和をとる。(this ^ val)
BigInteger not()
      自分のnotを返します。(~this)
自分が正数の場合に負数になる。
BigInteger andNot(BigInteger val)
      自分とvalのNot値とのandをとる。(this & ~val)
BigInteger clearBit(int n)
      指定したビットを0にします。すなわち ((this & ~(1<<n))を計算する。
      nが負数の場合はArithmeticExceptionが投げられる。
BigInteger testBit(int n)
      指定したビットが1ならtrueを返す。すなわち ((this & (1<<n)) != 0)を計算する。
      nが負数の場合はArithmeticExceptionが投げられる。
BigInteger setBit(int n)
      指定したビットを1にする。すなわち ((this | ~(1<<n))を計算する。
      nが負数の場合はArithmeticExceptionが投げられる。
BigInteger flipBit(int n)
      指定したビットを反転にします。すなわち ((this ^ (1<<n)) を計算します。
      nが負数の場合はArithmeticExceptionが投げられます。
BigInteger shiftLeft(int n)
      値が (this << n) の BigInteger を返す。シフト移動量 n が負の場合は、このメソッドは右シフトを実行する。
BigInteger shiftRight(int n)
      値が (this >> n) の BigInteger を返す。シフト移動量 n が負の場合は、このメソッドは左シフトを実行する。
int bitLength()
      2の補数で表現した場合に何バイトになるかを計算する。(ただし、符号ビットは除く)
      すなわち((ceil(log2(this < 0 ? -this : this+1))) と同じである。