Class Index | File Index

Classes


Class Math.BigInt

hapint BigInteger interface
Defined in: <hapint-1_9_2.es>.

Class Summary
Constructor Attributes Constructor Name and Description
 
Math.BigInt(a1, a2, a3)
constructor of hapint BigInteger objects.
Field Summary
Field Attributes Field Name and Description
<static>  
Math.BigInt.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.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.maxBitLength()
gets the maximum bit length of this BigInt implementation.
 
min(x)
minimum value.
 
mod(m)
modulo operation.
 
modInverse(m, algo)
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.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.unitBitLength()
gets the bit length of one unit in this BigInt implementation.
<static>  
Math.BigInt.valueOf(n)
creates a BigInt instance from the given primitive number.
<static>  
Math.BigInt.version()
gets the version of the specification of this BigInt.
 
xor(x)
bitwise XOR.
Class Detail
Math.BigInt(a1, a2, a3)
constructor of hapint 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 hapint 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(hapint, 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(hapint)
creates a copy of the given hapint a1.
Parameters:
{(string|number|Array.|BigInt|hapint)} a1
{(number|Array.|Random)=} a2
{Random=} a3
Field Detail
<static> Math.BigInt.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.factory
Method Detail
{BigInt} abs()
absolute value.
Returns:
{BigInt} abs(this)
See:
Math.BigInt#negate
Math.BigInt#signum

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

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

{BigInt} andNot(x)
bitwise AND NOT.
Parameters:
{BigInt} x
Returns:
{BigInt} this & ~ x
See:
Math.BigInt#and
Math.BigInt#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#bitLength
Math.BigInt#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#bitCount
Math.BigInt#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#flipBit
Math.BigInt#setBit
Math.BigInt#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#equals
Math.BigInt#min
Math.BigInt#max

{BigInt} divide(x)
division.
Parameters:
{BigInt} x
Returns:
{BigInt} floor( this / x ), or null if x is zero.
See:
Math.BigInt#divideAndRemainder
Math.BigInt#remainder
Math.BigInt#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#divide
Math.BigInt#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#intValue
Math.BigInt#longValue
Math.BigInt#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#compareTo

<static> {BigInteger} Math.BigInt.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.Unit
Math.BigInt.unitBitLength
Math.BigInt.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#clearBit
Math.BigInt#setBit
Math.BigInt#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#intValue
Math.BigInt#longValue
Math.BigInt#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#bitCount
Math.BigInt#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#longValue
Math.BigInt#floatValue
Math.BigInt#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#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#intValue
Math.BigInt#floatValue
Math.BigInt#doubleValue

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

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

{BigInt} min(x)
minimum value. returns the lesser one of this and x.
Parameters:
{BigInt} x
Returns:
{BigInt} the lesser
See:
Math.BigInt#compareTo
Math.BigInt#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#remainder

{BigInt} modInverse(m, algo)
modular multiplicative inverse. returns a BigInt x such that (this * x) mod m == 1
Parameters:
{BigInt} m
modulus
{object=} algo
a object specifying gcd algorithms and its parameters
Returns:
{BigInt} this-1 mod m, or null if m is not positive or such an inverse does not exist.
See:
Math.BigInt#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#mod
Math.BigInt#modInverse
Math.BigInt#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#divide
Math.BigInt#pow

{BigInt} negate()
negation.
Returns:
{BigInt} -this
See:
Math.BigInt#abs
Math.BigInt#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#isProbablePrime
Math.BigInt.probablePrime

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

{BigInt} or(x)
bitwise OR.
Parameters:
{BigInt} x
Returns:
{BigInt} this | x
See:
Math.BigInt#and
Math.BigInt#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#multiply
Math.BigInt#modPow

<static> {BigInt} Math.BigInt.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#isProbablePrime
Math.BigInt#nextProbablePrime

{BigInt} remainder(x)
remainder after division.
Parameters:
{BigInt} x
Returns:
{BigInt} this % x, or null if x is zero.
See:
Math.BigInt#divide
Math.BigInt#divideAndRemainder
Math.BigInt#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#clearBit
Math.BigInt#flipBit
Math.BigInt#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#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#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#abs
Math.BigInt#compareTo
Math.BigInt#negate

{BigInt} subtract(x)
subtraction.
Parameters:
{BigInt} x
Returns:
{BigInt} this - x
See:
Math.BigInt#add
Math.BigInt#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#clearBit
Math.BigInt#flipBit
Math.BigInt#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.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.factory
Math.BigInt.Unit
Math.BigInt.maxBitLength

<static> {BigInt} Math.BigInt.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.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#and
Math.BigInt#or

Documentation generated by JsDoc Toolkit