Packagecom.hurlant.math
Classpublic class BigInteger
SubclassesInteger



Public Properties
 PropertyDefined by
  t : int
BigInteger
Public Methods
 MethodDefined by
  
BigInteger(value:* = null, radix:int = 0, unsigned:Boolean = false)
BigInteger
  
|this|
BigInteger
  
BigInteger
  
BigInteger
  
BigInteger
  
bitCount():int
BigInteger
  
bitLength():int
returns the number of bits in this
BigInteger
  
byteValue():int
BigInteger
  
BigInteger
  
BigInteger
  
return + if this > v, - if this < v, 0 if equal
BigInteger
  
dispose():void
BigInteger
  
BigInteger
  
BigInteger
  
equals(a:BigInteger):Boolean
BigInteger
  
BigInteger
  
BigInteger
  
BigInteger
  
intValue():int
BigInteger
  
isProbablePrime(t:int):Boolean
BigInteger
  
BigInteger
  
BigInteger
  
BigInteger
  
BigInteger
  
BigInteger
  
this^e % m, 0 <= e < 2^32
BigInteger
  
BigInteger
  
nbv(value:int):BigInteger
[static] return bigint initialized to value
BigInteger
  
-this
BigInteger
  
BigInteger
  
BigInteger
  
pow(e:int):BigInteger
BigInteger
  
primify(bits:int, t:int):void
Tweak our BigInteger until it looks prime enough
BigInteger
  
BigInteger
  
BigInteger
  
BigInteger
  
BigInteger
  
shortValue():int
BigInteger
  
sigNum():int
BigInteger
  
BigInteger
  
testBit(n:int):Boolean
BigInteger
  
toArray(array:ByteArray):uint
BigInteger
  
toByteArray():ByteArray
BigInteger
  
toString(radix:Number = 16):String
BigInteger
  
valueOf():Number
best-effort attempt to fit into a Number.
BigInteger
  
BigInteger
Protected Methods
 MethodDefined by
  
BigInteger
  
bitwiseTo(a:BigInteger, op:Function, r:BigInteger):void
BigInteger
  
changeBit(n:int, op:Function):BigInteger
BigInteger
  
chunkSize(r:Number):int
BigInteger
  
fromRadix(s:String, b:int = 10):void
BigInteger
  
millerRabin(t:int):Boolean
BigInteger
  
modInt(n:int):int
BigInteger
  
nbi():*
BigInteger
  
toRadix(b:uint = 10):String
BigInteger
Public Constants
 ConstantDefined by
  BI_FP : int = 52
[static]
BigInteger
  DB : int = 30
[static]
BigInteger
  DM : int
[static]
BigInteger
  DV : int
[static]
BigInteger
  F1 : int = 22
[static]
BigInteger
  F2 : int = 8
[static]
BigInteger
  FV : Number
[static]
BigInteger
  lowprimes : Array
[static]
BigInteger
  lplim : int
[static]
BigInteger
  ONE : BigInteger
[static]
BigInteger
  ZERO : BigInteger
[static]
BigInteger
Property detail
aproperty
bi_internal var a:Array
sproperty 
bi_internal var s:int
tproperty 
public var t:int
Constructor detail
BigInteger()constructor
public function BigInteger(value:* = null, radix:int = 0, unsigned:Boolean = false)

Parameters
value:* (default = null)
 
radix:int (default = 0) — WARNING: If value is ByteArray, this holds the number of bytes to use.
 
unsigned:Boolean (default = false)
Method detail
abs()method
public function abs():BigInteger

|this|

Returns
BigInteger
add()method 
public function add(a:BigInteger):BigInteger

Parameters
a:BigInteger

Returns
BigInteger — this + a
addTo()method 
protected function addTo(a:BigInteger, r:BigInteger):void

Parameters
a:BigInteger
 
r:BigInteger — = this + a
am()method 
bi_internal function am(i:int, x:int, w:BigInteger, j:int, c:int, n:int):int

am: Compute w_j += (xhis_i), propagates carries, c is initial carry, returns final carry. c < 3value, x < 2value, this_i < dvalue

Parameters
i:int
 
x:int
 
w:BigInteger
 
j:int
 
c:int
 
n:int

Returns
int
and()method 
public function and(a:BigInteger):BigIntegerParameters
a:BigInteger

Returns
BigInteger
andNot()method 
public function andNot(a:BigInteger):BigIntegerParameters
a:BigInteger

Returns
BigInteger
bitCount()method 
public function bitCount():int

Returns
int — number of set bits
bitLength()method 
public function bitLength():int

returns the number of bits in this

Returns
int
bitwiseTo()method 
protected function bitwiseTo(a:BigInteger, op:Function, r:BigInteger):void

Parameters
a:BigInteger — a BigInteger to perform the operation with
 
op:Function — a Function implementing the operation
 
r:BigInteger — a BigInteger to store the result of the operation
byteValue()method 
public function byteValue():int

Returns
int — value as byte
changeBit()method 
protected function changeBit(n:int, op:Function):BigInteger

Parameters
n:int
 
op:Function

Returns
BigInteger — this op (1<
chunkSize()method 
protected function chunkSize(r:Number):int

Parameters
r:Number

Returns
int — x s.t. r^x < DV
clamp()method 
bi_internal function clamp():void

clamp off excess high words

clearBit()method 
public function clearBit(n:int):BigInteger

Parameters
n:int

Returns
BigInteger — this & ~(1<
clone()method 
public function clone():BigInteger

Returns
BigInteger
compareTo()method 
public function compareTo(v:BigInteger):int

return + if this > v, - if this < v, 0 if equal

Parameters
v:BigInteger

Returns
int
copyTo()method 
bi_internal function copyTo(r:BigInteger):void

copy this to r

Parameters
r:BigInteger
dAddOffset()method 
bi_internal function dAddOffset(n:int, w:int):void

this += n << w words, this >= 0

Parameters
n:int
 
w:int
dispose()method 
public function dispose():void
divide()method 
public function divide(a:BigInteger):BigInteger

Parameters
a:BigInteger

Returns
BigInteger — this / a
divideAndRemainder()method 
public function divideAndRemainder(a:BigInteger):Array

Parameters
a:BigInteger

Returns
Array — [this/a, this%a]
divRemTo()method 
bi_internal function divRemTo(m:BigInteger, q:BigInteger = null, r:BigInteger = null):void

divide this by m, quotient and remainder to q, r (HAC 14.20) r != q, this != m. q or r may be null.

Parameters
m:BigInteger
 
q:BigInteger (default = null)
 
r:BigInteger (default = null)
dlShiftTo()method 
bi_internal function dlShiftTo(n:int, r:BigInteger):void

r = this << nB

Parameters
n:int
 
r:BigInteger
dMultiply()method 
bi_internal function dMultiply(n:int):void

this n, this >=0, 1 < n < DV

Parameters
n:int
drShiftTo()method 
bi_internal function drShiftTo(n:int, r:BigInteger):void

r = this >> nB

Parameters
n:int
 
r:BigInteger
equals()method 
public function equals(a:BigInteger):BooleanParameters
a:BigInteger

Returns
Boolean
exp()method 
bi_internal function exp(e:int, z:IReduction):BigInteger

this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79)

Parameters
e:int
 
z:IReduction

Returns
BigInteger
flipBit()method 
public function flipBit(n:int):BigInteger

Parameters
n:int

Returns
BigInteger — this ^ (1<
fromArray()method 
bi_internal function fromArray(value:ByteArray, length:int, unsigned:Boolean = false):void

set from ByteArray and length, starting a current position If length goes beyond the array, pad with zeroes.

Parameters
value:ByteArray
 
length:int
 
unsigned:Boolean (default = false)
fromInt()method 
bi_internal function fromInt(value:int):void

set from integer value "value", -DV <= value < DV

Parameters
value:int
fromRadix()method 
protected function fromRadix(s:String, b:int = 10):void

Parameters
s:String — a string to convert from using radix.
 
b:int (default = 10) — a radix
gcd()method 
public function gcd(a:BigInteger):BigInteger

Parameters
a:BigInteger

Returns
BigInteger — gcd(this, a) (HAC 14.54)
getLowestSetBit()method 
public function getLowestSetBit():int

Returns
int — index of lowest 1-bit (or -1 if none)
intAt()method 
bi_internal function intAt(str:String, index:int):intParameters
str:String
 
index:int

Returns
int
intValue()method 
public function intValue():int

Returns
int — value as integer
invDigit()method 
bi_internal function invDigit():int

return "-1/this % 2^DB"; useful for Mont. reduction justification: xy == 1 (mod n) xy = 1+km xy(2-xy) = (1+km)(1-km) x[y(2-xy)] = 1-k^2.m^2 x[y(2-xy)] == 1 (mod m^2) if y is 1/x mod m, then y(2-xy) is 1/x mod m^2 should reduce x and y(2-xy) by m^2 at each step to keep size bounded [XXX unit test the living shit out of this.]

Returns
int
isEven()method 
bi_internal function isEven():Boolean

true iff this is even

Returns
Boolean
isProbablePrime()method 
public function isProbablePrime(t:int):Boolean

Parameters
t:int

Returns
Boolean — primality with certainty >= 1-.5^t
lShiftTo()method 
bi_internal function lShiftTo(n:int, r:BigInteger):void

r = this << n

Parameters
n:int
 
r:BigInteger
max()method 
public function max(a:BigInteger):BigIntegerParameters
a:BigInteger

Returns
BigInteger
millerRabin()method 
protected function millerRabin(t:int):Boolean

Parameters
t:int

Returns
Boolean — true if probably prime (HAC 4.24, Miller-Rabin)
min()method 
public function min(a:BigInteger):BigIntegerParameters
a:BigInteger

Returns
BigInteger
mod()method 
public function mod(v:BigInteger):BigInteger

Parameters
v:BigInteger

Returns
BigInteger — this % v
modInt()method 
protected function modInt(n:int):int

Parameters
n:int

Returns
int — this % n, n < 2^DB
modInverse()method 
public function modInverse(m:BigInteger):BigInteger

Parameters
m:BigInteger

Returns
BigInteger — 1/this %m (HAC 14.61)
modPow()method 
public function modPow(e:BigInteger, m:BigInteger):BigInteger

Parameters
e:BigInteger
 
m:BigInteger

Returns
BigInteger — this^e % m (HAC 14.85)
modPowInt()method 
public function modPowInt(e:int, m:BigInteger):BigInteger

this^e % m, 0 <= e < 2^32

Parameters
e:int
 
m:BigInteger

Returns
BigInteger
multiply()method 
public function multiply(a:BigInteger):BigInteger

Parameters
a:BigInteger

Returns
BigInteger — this a
multiplyLowerTo()method 
bi_internal function multiplyLowerTo(a:BigInteger, n:int, r:BigInteger):void

Parameters
a:BigInteger
 
n:int
 
r:BigInteger — = lower n words of "this a", a.t <= n
multiplyTo()method 
bi_internal function multiplyTo(v:BigInteger, r:BigInteger):void

r = this v, r != this,a (HAC 14.12) "this" should be the larger one if appropriate

Parameters
v:BigInteger
 
r:BigInteger
multiplyUpperTo()method 
bi_internal function multiplyUpperTo(a:BigInteger, n:int, r:BigInteger):void

Parameters
a:BigInteger
 
n:int
 
r:BigInteger — = "this a" without lower n words, n > 0
nbi()method 
protected function nbi():*

Returns
*
nbits()method 
bi_internal function nbits(x:int):int

returns bit length of the integer x

Parameters
x:int

Returns
int
nbv()method 
public static function nbv(value:int):BigInteger

return bigint initialized to value

Parameters
value:int

Returns
BigInteger
negate()method 
public function negate():BigInteger

-this

Returns
BigInteger
not()method 
public function not():BigInteger

Returns
BigInteger
or()method 
public function or(a:BigInteger):BigIntegerParameters
a:BigInteger

Returns
BigInteger
pow()method 
public function pow(e:int):BigInteger

Parameters
e:int

Returns
BigInteger — this^e
primify()method 
public function primify(bits:int, t:int):void

Tweak our BigInteger until it looks prime enough

Parameters
bits:int
 
t:int
remainder()method 
public function remainder(a:BigInteger):BigIntegerParameters
a:BigInteger

Returns
BigInteger
rShiftTo()method 
bi_internal function rShiftTo(n:int, r:BigInteger):void

r = this >> n

Parameters
n:int
 
r:BigInteger
setBit()method 
public function setBit(n:int):BigInteger

Parameters
n:int

Returns
BigInteger — this | (1<
shiftLeft()method 
public function shiftLeft(n:int):BigIntegerParameters
n:int

Returns
BigInteger
shiftRight()method 
public function shiftRight(n:int):BigIntegerParameters
n:int

Returns
BigInteger
shortValue()method 
public function shortValue():int

Returns
int — value as short (assumes DB>=16)
sigNum()method 
public function sigNum():int

Returns
int — 0 if this ==0, 1 if this >0
squareTo()method 
bi_internal function squareTo(r:BigInteger):void

r = this^2, r != this (HAC 14.16)

Parameters
r:BigInteger
subTo()method 
bi_internal function subTo(v:BigInteger, r:BigInteger):void

r = this - v

Parameters
v:BigInteger
 
r:BigInteger
subtract()method 
public function subtract(a:BigInteger):BigInteger

Parameters
a:BigInteger

Returns
BigInteger — this - a
testBit()method 
public function testBit(n:int):Boolean

Parameters
n:int

Returns
Boolean — true iff nth bit is set
toArray()method 
public function toArray(array:ByteArray):uintParameters
array:ByteArray

Returns
uint
toByteArray()method 
public function toByteArray():ByteArray

Returns
ByteArray — a byte array.
toRadix()method 
protected function toRadix(b:uint = 10):String

Parameters
b:uint (default = 10) — radix to use

Returns
String — a string representing the integer converted to the radix.
toString()method 
public function toString(radix:Number = 16):StringParameters
radix:Number (default = 16)

Returns
String
valueOf()method 
public function valueOf():Number

best-effort attempt to fit into a Number. precision can be lost if it just can't fit.

Returns
Number
xor()method 
public function xor(a:BigInteger):BigIntegerParameters
a:BigInteger

Returns
BigInteger
Constant detail
BI_FPconstant
public static const BI_FP:int = 52
DBconstant 
public static const DB:int = 30
DMconstant 
public static const DM:int
DVconstant 
public static const DV:int
F1constant 
public static const F1:int = 22
F2constant 
public static const F2:int = 8
FVconstant 
public static const FV:Number
lowprimesconstant 
public static const lowprimes:Array
lplimconstant 
public static const lplim:int
ONEconstant 
public static const ONE:BigInteger
ZEROconstant 
public static const ZERO:BigInteger