A collection of static helper functions for performing arithmetic
on BigInt_
objects.
Static methods
staticadd(result:MutableBigInt_, operand1:BigInt_, operand2:BigInt_):Void
Add big integer operand2
to big integer operand1
and put
the result into big integer result
.
Ok for result
, operand1
, and operand2
to be the same object.
staticaddInt(result:MutableBigInt_, operand1:BigInt_, operand2:Int):Void
Add integer operand2
to big integer operand1
and put the
result into big integer result
.
Ok for result
and operand1
to be the same object.
staticarithmeticShiftLeft(result:MutableBigInt_, operand1:BigInt_, operand2:Int):Void
Shift big integer operand1
to the left by operand2
bits
and put the result into big integer result
.
Ok for result
and operand1
to be the same object.
staticarithmeticShiftRight(result:MutableBigInt_, operand1:BigInt_, operand2:Int):Void
Shift big integer operand1
to the right by operand2
bits
and put the result into big integer result
.
Ok for result
and operand1
to be the same object.
staticinlinebitwiseAnd(operand1:BigInt_, operand2:BigInt_):BigInt_
Returns the bitwise AND of two big integers.
Returns:
A new BigInt_
holding the result.
staticinlinebitwiseAndInt(operand1:BigInt_, operand2:Int):Int
Returns the bitwise AND of operand1
with operand2
.
staticinlinebitwiseNot(operand:BigInt_):BigInt_
Returns the bitwise NOT (inversion) of a big integer.
Returns:
A new BigInt_
holding the result.
staticinlinebitwiseOr(operand1:BigInt_, operand2:BigInt_):BigInt_
Returns the bitwise OR of operand1
with operand2
.
staticinlinebitwiseXor(operand1:BigInt_, operand2:BigInt_):BigInt_
Returns the bitwise XOR of two big integers.
Returns:
A new BigInt_
holding the result.
staticcompare(a:BigInt_, b:BigInt_):Int
Compare two big integers.
Returns -1 if a < b
; otherwise
returns 1 if a > b
; otherwise
returns 0 (a == b
).
staticcompareInt(a:BigInt_, b:Int):Int
Compare a big integer with an Int.
Returns -1 if a < b
; otherwise
returns 1 if a > b
; otherwise
returns 0 (a == b
).
staticdivide(dividend:BigInt_, divisor:BigInt_, quotientOut:MutableBigInt_, remainderOut:MutableBigInt_, ?work:MutableBigInt_):Void
Divide the big integer dividend
by the big integer divisor
.
The quotient of the division is put into quotientOut
;
the remainder is put into remainderOut
.
remainderOut
may be null
if the remainder value is not
needed.
dividend
and divisor
may refer to the same object.
quotientOut
and remainderOut
must not refer to the same
object; but either may refer to the inputs.
work
, if supplied, must not refer to any of the inputs.
staticdivideInt(dividend:BigInt_, divisor:Int, quotientOut:MutableBigInt_, ?work:MutableBigInt_):Int
Divide the big integer dividend
by the integer divisor
.
The quotient of the division is put into quotientOut
;
the remainder is the return value.
quotientOut
may refer to dividend
.
work
, if supplied, must not refer to any of the inputs.
staticfloorLog2(input:BigInt_):Int
Returns floor(log2(input))
.
Parameters:
input | The |
---|
Returns:
The integer base-2 logarithm.
staticinlinegetBit(value:BigInt_, index:Int):Int
Returns the value, 0 or 1, of the bit at 2^index
place.
staticmultiply(result:MutableBigInt_, operand1:BigInt_, operand2:BigInt_):Void
Multiply big integer operand1
by big integer operand2
and
put the result into result
.
result
may not refer the same object as either operand1
or operand2
; however, operand1
and operand2
may be the
same object.
staticmultiplyInt(result:MutableBigInt_, operand1:BigInt_, operand2:Int):Void
Multiply big integer operand1
by integer operand2
and put
the result into result
.
result
may not refer the same object as either operand1
or operand2
; however, operand1
and operand2
may be the
same object.
staticmultiplyKaratsuba(result:MutableBigInt_, x:BigInt_, y:BigInt_):Void
Multiply two big integers using the Karatsuba algorithm for performance.
Parameters:
result | The |
---|---|
x | The first operand. |
y | The second operand. |
staticnegate(result:MutableBigInt_, operand:BigInt_):Void
Perform the unary negation of big integer operand
and put
the result into big integer result
.
Ok for result
and operand
to be the same object.
staticsubtract(result:MutableBigInt_, operand1:BigInt_, operand2:BigInt_):Void
Subtract big integer operand2
from big integer operand1
and put the result into big integer result
.
Ok for result
, operand1
, and operand2
to be the same object.
staticsubtractInt(result:MutableBigInt_, operand1:BigInt_, operand2:Int):Void
Subtract integer operand2
from big integer operand1
and
put the result into big integer result
.
Ok for result
and operand1
to be the same object.