Class Index | File Index

Classes


Class Math.BigInt.ArrayBigInt

Array-based BigInteger implementation. Note that the maximum number of digits is limited.
Defined in: <hapint-1_9_2.es>.

Class Summary
Constructor Attributes Constructor Name and Description
 
constructor of arbint BigInteger objects.
Field Summary
Field Attributes Field Name and Description
<static>  
Math.BigInt.ArrayBigInt.Unit
the element class used in this BigInt implementation.
Method Summary
Method Attributes Method Name and Description
 
abs()
absolute value.
 
add(x)
addition.
 
and(x)
bitwise AND.
 
andNot(x)
bitwise AND NOT.
 
bitCount(asbig)
counts set bits.
 
bitLength(asbig)
bit length.
 
clears a bit.
 
clones this BigInt.
 
compares this BigInt with another BigInt x.
 
divide(x)
division.
 
division with a remainder.
 
converts to double precision floating-point number.
 
equals(x)
compares this BigInt with another BigInt x for equality.
<static>  
Math.BigInt.ArrayBigInt.factory(params)
creates a new BigInt implementation.
 
flips a bit.
 
converts to single precision floating-point number.
 
gcd(x, algo)
greatest common divisor.
 
lowest set bit index.
 
gets a 32-bit hash code.
 
converts to 32-bit integer.
 
primality test of this BigInt.
 
converts to 64-bit integer.
 
max(x)
maximum value.
<static>  
Math.BigInt.ArrayBigInt.maxBitLength()
gets the maximum bit length of this BigInt implementation.
 
min(x)
minimum value.
 
mod(m)
modulo operation.
 
modular multiplicative inverse.
 
modPow(x, m, algo)
modular exponentiation.
 
multiply(x, algo)
multiplication.
 
negation.
 
returns the next BigInt which is probably prime.
 
not()
bitwise NOT.
 
or(x)
bitwise OR.
 
pow(n, algo)
exponentiation.
<static>  
Math.BigInt.ArrayBigInt.probablePrime(n, rnd)
returns a random BigInt with the specified bit length which is probably prime.
 
remainder after division.
 
setBit(n)
sets a bit.
 
left bit shift.
 
right bit shift.
 
signum function.
 
subtraction.
 
tests a bit.
 
converts to an Array of bytes.
 
toString(radix)
converts to a string.
<static>  
Math.BigInt.ArrayBigInt.unitBitLength()
gets the bit length of one unit in this BigInt implementation.
<static>  
Math.BigInt.ArrayBigInt.valueOf(n)
creates a BigInt instance from the given primitive number.
<static>  
Math.BigInt.ArrayBigInt.version()
gets the version of the specification of this BigInt.
 
xor(x)
bitwise XOR.
Class Detail
Math.BigInt.ArrayBigInt(a1, a2, a3)
constructor of arbint BigInteger objects. The 9 different constructors are overloaded. The 6 of 9 are compatible with Java's BigInteger. The other 3 are original: They accept a arbint object.
constructor(string)
creates a BigInt instance from the given string representation. The default radix 10 is used.
constructor(string, number)
creates a BigInt instance from the given string representation, with the specified radix as the 2nd parameter.
constructor(Array.<byte>)
creates a BigInt instance from a byte Array containing the 2's-complement binary representation. The Array is assumed to be in big-endian byte-order.
constructor(number, Array.<byte>)
creates a BigInt instance from a sign-magnitude representation. The 1st parameter is translated as the signum. The 2nd parameter is a byte Array in big-endian byte-order that represents the magnitude.
constructor(number, Random)
constructor(BigInt, Random)
constructor(arbint, Random)
creates a nonnegative random BigInt instance. The values are uniformly distributed over the range 0 to 2a1 - 1 (inclusive). The uniformity assumes that a fair source of random bits is provided in the 2nd parameter a2. A random number generator function compatible with Math.random, or an object compatible with Java's java.util.Random that has the nextBytes(byte[]) method, can be accepted in a2.
constructor(number, number, Random)
creates a positive random BigInt instance which is probably prime, with the specified bit length as the 1st parameter a1. The 2nd parameter is a measure of the certainty. The probability that the new BigInt is prime exceeds 1 - 1 / 2 a2. The execution time of this constructor is proportional to the value of a2. A random number generator function compatible with Math.random, or an object compatible with Java's java.util.Random that has the nextBytes(byte[]) method, can be accepted in a3.
constructor(arbint)
creates a copy of the given arbint a1.
Parameters:
{(string|number|Array.|BigInt|arbint)} a1
{(number|Array.|Random)=} a2
{Random=} a3
Field Detail
<static> Math.BigInt.ArrayBigInt.Unit
the element class used in this BigInt implementation. The class can be given as the argument of the factory method. Otherwise, the internal default class is used.
See:
Math.BigInt.ArrayBigInt.factory
Method Detail
{BigInt} abs()
absolute value.
Returns:
{BigInt} abs(this)
See:
Math.BigInt.ArrayBigInt#negate
Math.BigInt.ArrayBigInt#signum

{BigInt} add(x)
addition.
Parameters:
{BigInt} x
Returns:
{BigInt} this + x
See:
Math.BigInt.ArrayBigInt#subtract

{BigInt} and(x)
bitwise AND.
Parameters:
{BigInt} x
Returns:
{BigInt} this & x
See:
Math.BigInt.ArrayBigInt#andNot
Math.BigInt.ArrayBigInt#or
Math.BigInt.ArrayBigInt#xor

{BigInt} andNot(x)
bitwise AND NOT.
Parameters:
{BigInt} x
Returns:
{BigInt} this & ~ x
See:
Math.BigInt.ArrayBigInt#and
Math.BigInt.ArrayBigInt#not

{(number|BigInt)} bitCount(asbig)
counts set bits. returns the number of bits in the 2's complement representation of this BigInt that differ from its sign bit. When set asbig false or omitted, the resulting count is truncated in 32 bits and returned as primitive number value (possibly, low-level int32). Note that the 32-bit truncated value may be represented as negative.
Parameters:
{boolean=} asbig
optional. If true, the count is returned as BigInt. otherwise (default), as primitive number.
Returns:
{(number|BigInt)} bit count
See:
Math.BigInt.ArrayBigInt#bitLength
Math.BigInt.ArrayBigInt#getLowestSetBit

{(number|BigInt)} bitLength(asbig)
bit length. returns the number of bits in the minimal 2's-complement representation of this BigInt, excluding a sign bit. When set asbig false or omitted, the resulting bit length is truncated in 32 bits and returned as primitive number value (possibly, low-level int32). Note that the 32-bit truncated value may be represented as negative.
Parameters:
{boolean=} asbig
optional. If true, the bit length is returned as BigInt. otherwise (default), as primitive number.
Returns:
{(number|BigInt)} bit length. ceil( log2(this < 0 ? -this : this + 1) )
See:
Math.BigInt.ArrayBigInt#bitCount
Math.BigInt.ArrayBigInt#getLowestSetBit

{BigInt} clearBit(n)
clears a bit. returns a BigInt whose value is equivalent to this BigInt with the designated bit cleared.
Parameters:
{(number|BigInt)} n
index of bit to clear, >= 0
Returns:
{BigInt} this & ~ (1 << n)
See:
Math.BigInt.ArrayBigInt#flipBit
Math.BigInt.ArrayBigInt#setBit
Math.BigInt.ArrayBigInt#testBit

{BigInt} clone()
clones this BigInt.
Returns:
{BigInt}

{BigInt} compareTo(x)
compares this BigInt with another BigInt x. To perform each of the 6 ordinal comparisons (<, >, <=, >=, ==, !=), use this method as: this.compareTo(x) <R> 0 , where <R> is one of the 6 comparison operators.
Parameters:
{BigInt} x
Returns:
{BigInt} -1, 0 or 1, means that this is less than, equal to, or greater than x.
See:
Math.BigInt.ArrayBigInt#equals
Math.BigInt.ArrayBigInt#min
Math.BigInt.ArrayBigInt#max

{BigInt} divide(x)
division.
Parameters:
{BigInt} x
Returns:
{BigInt} floor( this / x ), or null if x is zero.
See:
Math.BigInt.ArrayBigInt#divideAndRemainder
Math.BigInt.ArrayBigInt#remainder
Math.BigInt.ArrayBigInt#multiply

{Array.} divideAndRemainder(x, algo)
division with a remainder.
Parameters:
{BigInt} x
{object=} algo
a object specifying division algorithms and its parameters
Returns:
{Array.} [ floor( this / x ), this % x ], or null if x is zero.
See:
Math.BigInt.ArrayBigInt#divide
Math.BigInt.ArrayBigInt#remainder

{number} doubleValue()
converts to double precision floating-point number. That is ECMAScript's primitive number format. If ECMAScript's primitive number cannot represent the value equivalent to this BigInt, a value with less significand precision or Infinity is returned.
Returns:
{number}
See:
Math.BigInt.ArrayBigInt#intValue
Math.BigInt.ArrayBigInt#longValue
Math.BigInt.ArrayBigInt#floatValue

{boolean} equals(x)
compares this BigInt with another BigInt x for equality.
Parameters:
{BigInt} x
Returns:
{boolean} true if and only if the x is numerically equal to this.
See:
Math.BigInt.ArrayBigInt#compareTo

<static> {BigInteger} Math.BigInt.ArrayBigInt.factory(params)
creates a new BigInt implementation.
Parameters:
{object} params
an object as named parameters. all is optional. {?BigInteger=} unit the element class of the created BigInt class {?number=} unitBitLength bit length of one unit in the created BigInt {?Array=} algoMul multiplication algorithm {?Array=} algoDiv division algorithm {?Array=} algoPow exponentiation algorithm {?Array=} algoModPow modular exponentiation algorithm
Returns:
{BigInteger} a class (constructor)
See:
Math.BigInt.ArrayBigInt.Unit
Math.BigInt.ArrayBigInt.unitBitLength
Math.BigInt.ArrayBigInt.maxBitLength

{BigInt} flipBit(n)
flips a bit. returns a BigInt whose value is equivalent to this BigInt with the designated bit flipped.
Parameters:
{(number|BigInt)} n
index of bit to flip, >= 0
Returns:
{BigInt} this ^ (1 << n)
See:
Math.BigInt.ArrayBigInt#clearBit
Math.BigInt.ArrayBigInt#setBit
Math.BigInt.ArrayBigInt#testBit

{number} floatValue()
converts to single precision floating-point number. That has 24-bit significand precision (including implicit 1) and 8-bit exponent width. If this value cannot be represented in the single precision format, a number with less significand precision or Infinity is returned.
Returns:
{number}
See:
Math.BigInt.ArrayBigInt#intValue
Math.BigInt.ArrayBigInt#longValue
Math.BigInt.ArrayBigInt#doubleValue

{BigInt} gcd(x, algo)
greatest common divisor. returns the GCD of abs(this) and abs(x). 0 is returned if this == 0 && x == 0
Parameters:
{BigInt} x
{object=} algo
a object specifying gcd algorithms and its parameters
Returns:
{BigInt} gcd( abs(this), abs(x) )

{(number|BigInt)} getLowestSetBit(asbig)
lowest set bit index. returns the index of the lowest-order one bit in this BigInt. In other words, the number of zero bits to the right of the rightmost one bit. returns -1 if this contains no one bit. When set asbig false or omitted, the resulting index is truncated in 32 bits and returned as primitive number value (possibly, low-level int32). Note that the 32-bit truncated value may be represented as negative.
Parameters:
{boolean=} asbig
optional. If true, the bit length is returned as BigInt. otherwise (default), as primitive number.
Returns:
{(number|BigInt)} index of the lowest set bit. this == 0 ? -1 : log2( this & -this )
See:
Math.BigInt.ArrayBigInt#bitCount
Math.BigInt.ArrayBigInt#bitLength

{number} hashCode()
gets a 32-bit hash code.
Returns:
{number} hash code

{number} intValue()
converts to 32-bit integer. If this BigInt cannot be represented by 32 bits, only the low-order 32 bits are returned. Note that the conversion can return a result with the opposite sign.
Returns:
{number} this & 0xffffffff
See:
Math.BigInt.ArrayBigInt#longValue
Math.BigInt.ArrayBigInt#floatValue
Math.BigInt.ArrayBigInt#doubleValue

{boolean} isProbablePrime(c)
primality test of this BigInt. If definitely composite, false is returned.
Parameters:
{BigInt} c
measure of the certainty. This method returns true when the probability that this BigInt is prime exceeds 1 - 1 / 2 c. The execution time of this method is proportional to the value of c. If c is not positive, always returns true.
Returns:
{boolean} true if this is probably prime, false if this is definitely composite.
See:
Math.BigInt.ArrayBigInt#nextProbablePrime
Math.BigInt.probablePrime

{BigInt} longValue()
converts to 64-bit integer. If this BigInt cannot be represented by 64 bits, only the low-order 64 bits are returned. Note that the conversion can return a result with the opposite sign. To return a BigInt is the only point where this implementation is out of Java's BigInteger specification, because ECMAScript does not have 64-bit integers or its numeric alternatives.
Returns:
{BigInt} this & 0xffffffffffffffff
See:
Math.BigInt.ArrayBigInt#intValue
Math.BigInt.ArrayBigInt#floatValue
Math.BigInt.ArrayBigInt#doubleValue

{BigInt} max(x)
maximum value. returns the greater one of this and x.
Parameters:
{BigInt} x
Returns:
{BigInt} the greater
See:
Math.BigInt.ArrayBigInt#compareTo
Math.BigInt.ArrayBigInt#min

<static> {number} Math.BigInt.ArrayBigInt.maxBitLength()
gets the maximum bit length of this BigInt implementation. This class always returns Infinity.
Returns:
{number} Infinity
See:
Math.BigInt.ArrayBigInt.unitBitLength

{BigInt} min(x)
minimum value. returns the lesser one of this and x.
Parameters:
{BigInt} x
Returns:
{BigInt} the lesser
See:
Math.BigInt.ArrayBigInt#compareTo
Math.BigInt.ArrayBigInt#max

{BigInt} mod(m)
modulo operation. The difference from remainder is that this always returns a nonnegative BigInt.
Parameters:
{BigInt} m
modulus
Returns:
{BigInt} this mod m, or null if m is not positive.
See:
Math.BigInt.ArrayBigInt#remainder

{BigInt} modInverse(m)
modular multiplicative inverse. returns a BigInt x such that (this * x) mod m == 1
Parameters:
{BigInt} m
modulus
Returns:
{BigInt} this-1 mod m, or null if m is not positive or such an inverse does not exist.
See:
Math.BigInt.ArrayBigInt#mod

{BigInt} modPow(x, m, algo)
modular exponentiation. In contrast to pow, this permits negative exponents.
Parameters:
{BigInt} x
exponent
{BigInt} m
modulus
{object=} algo
a object specifying exponentiation algorithms and its parameters
Returns:
{BigInt} pow( this, x ) mod m, or null if m is not positive, or, x is negative and the modular inverse of this does not exist.
See:
Math.BigInt.ArrayBigInt#mod
Math.BigInt.ArrayBigInt#modInverse
Math.BigInt.ArrayBigInt#pow

{BigInt} multiply(x, algo)
multiplication.
Parameters:
{BigInt} x
{object=} algo
a object specifying multiplication algorithms and its parameters
Returns:
{BigInt} this * x
See:
Math.BigInt.ArrayBigInt#divide
Math.BigInt.ArrayBigInt#pow

{BigInt} negate()
negation.
Returns:
{BigInt} -this
See:
Math.BigInt.ArrayBigInt#abs
Math.BigInt.ArrayBigInt#signum

{BigInt} nextProbablePrime()
returns the next BigInt which is probably prime. The probability that the returned BigInt is composite does not exceed 1 / 2100. The algorithm never skips over a prime in searching. That is, given that x is returned, there is no prime y such that this < y < x.
Returns:
{BigInt} the first BigInt greater than this that is probably prime.
See:
Math.BigInt.ArrayBigInt#isProbablePrime
Math.BigInt.ArrayBigInt.probablePrime

{BigInt} not()
bitwise NOT.
Returns:
{BigInt} ~ this
See:
Math.BigInt.ArrayBigInt#andNot
Math.BigInt.ArrayBigInt#negate

{BigInt} or(x)
bitwise OR.
Parameters:
{BigInt} x
Returns:
{BigInt} this | x
See:
Math.BigInt.ArrayBigInt#and
Math.BigInt.ArrayBigInt#xor

{BigInt} pow(n, algo)
exponentiation. returns a BigInt whose value is equivalent to thisn. Note that n can be a primitive number or BigInt.
Parameters:
{(number|BigInt)} n
exponent to which this BigInt is to be raised.
{object=} algo
a object specifying exponentiation algorithms and its parameters
Returns:
{BigInt} pow(this, n), or null if n is negative.
See:
Math.BigInt.ArrayBigInt#multiply
Math.BigInt.ArrayBigInt#modPow

<static> {BigInt} Math.BigInt.ArrayBigInt.probablePrime(n, rnd)
returns a random BigInt with the specified bit length which is probably prime. The probability that the returned BigInt is composite does not exceed 1 / 2100.
Parameters:
{number} n
bit length of the returned BigInt
{Random} rnd
source of random bits used to select candidates to be tested for primality. A random number generator function compatible with Math.random, or an object compatible with Java's java.util.Random that has the nextBytes(byte[]) method, can be accepted.
Returns:
{BigInt}
See:
Math.BigInt.ArrayBigInt#isProbablePrime
Math.BigInt.ArrayBigInt#nextProbablePrime

{BigInt} remainder(x)
remainder after division.
Parameters:
{BigInt} x
Returns:
{BigInt} this % x, or null if x is zero.
See:
Math.BigInt.ArrayBigInt#divide
Math.BigInt.ArrayBigInt#divideAndRemainder
Math.BigInt.ArrayBigInt#mod

{BigInt} setBit(n)
sets a bit. returns a BigInt whose value is equivalent to this BigInt with the designated bit set.
Parameters:
{(number|BigInt)} n
index of bit to set, >= 0
Returns:
{BigInt} this | (1 << n)
See:
Math.BigInt.ArrayBigInt#clearBit
Math.BigInt.ArrayBigInt#flipBit
Math.BigInt.ArrayBigInt#testBit

{BigInt} shiftLeft(n)
left bit shift. returns a BigInt whose value is equivalent to this << n.
Parameters:
{(number|BigInt)} n
shift distance in bits. If negative, a right shift is performed.
Returns:
{BigInt} this * pow( 2, n )
See:
Math.BigInt.ArrayBigInt#shiftRight

{BigInt} shiftRight(n)
right bit shift. returns a BigInt whose value is equivalent to this >> n.
Parameters:
{(number|BigInt)} n
shift distance in bits. If negative, a left shift is performed.
Returns:
{BigInt} floor( this / pow( 2, n ) )
See:
Math.BigInt.ArrayBigInt#shiftLeft

{number} signum()
signum function. returns an integer indicating the sign of this BigInt.
Returns:
{number} -1, 0 or 1 as the value of this BigInt is negative, zero or positive.
See:
Math.BigInt.ArrayBigInt#abs
Math.BigInt.ArrayBigInt#compareTo
Math.BigInt.ArrayBigInt#negate

{BigInt} subtract(x)
subtraction.
Parameters:
{BigInt} x
Returns:
{BigInt} this - x
See:
Math.BigInt.ArrayBigInt#add
Math.BigInt.ArrayBigInt#negate

{BigInt} testBit(n)
tests a bit. returns true if and only if the designated bit is set.
Parameters:
{(number|BigInt)} n
index of bit to test, >= 0
Returns:
{BigInt} (this & (1 << n)) != 0
See:
Math.BigInt.ArrayBigInt#clearBit
Math.BigInt.ArrayBigInt#flipBit
Math.BigInt.ArrayBigInt#setBit

{Array.} toByteArray()
converts to an Array of bytes. The Array of bytes (8-bit nonnegative integers) will contains the 2's-complement representation of this in big-endian byte-order. The Array contains at least one sign bit. If this BigInt cannot be represented by byte Array, only the low-order part is returned.
Returns:
{Array.}

{string} toString(radix)
converts to a string. The parameter radix is optional: default is 10. If the radix is outside the range from 2 to 36 (inclusive), 10 is used. The resulting representation is compatible with the constructor(string, number).
Parameters:
{number=} radix
optional. radix of the string representation. If omitted or out of range, 10 is used.
Returns:
{string}

<static> {number} Math.BigInt.ArrayBigInt.unitBitLength()
gets the bit length of one unit in this BigInt implementation. The unit bit length can be specified by the argument of the factory method. Otherwise, it is automatically determined from the maximum bit length of the Unit class.
Returns:
{number} number of bits
See:
Math.BigInt.ArrayBigInt.factory
Math.BigInt.ArrayBigInt.Unit
Math.BigInt.ArrayBigInt.maxBitLength

<static> {BigInt} Math.BigInt.ArrayBigInt.valueOf(n)
creates a BigInt instance from the given primitive number.
Parameters:
{number} n
a finite primitive number to be converted to a BigInt.
Returns:
{BigInt}

<static> {string} Math.BigInt.ArrayBigInt.version()
gets the version of the specification of this BigInt.
Returns:
{string} version string

{BigInt} xor(x)
bitwise XOR.
Parameters:
{BigInt} x
Returns:
{BigInt} this ^ x
See:
Math.BigInt.ArrayBigInt#and
Math.BigInt.ArrayBigInt#or

Documentation generated by JsDoc Toolkit