Class BigIntegerAlgebra
- java.lang.Object
-
- java.lang.Number
-
- java.math.BigInteger
-
- BigIntegerAlgebra
-
- All Implemented Interfaces:
Serializable
,Comparable<BigInteger>
public class BigIntegerAlgebra extends BigInteger
Wrapper forjava.math.
BigInteger
. Required for mixed arithmetic withint
orlong
operands becausejava.math.
BigInteger
does not implement aBigInteger(long)
constructor.
Note: As classBigIntegerAlgebra
extends classjava.math.BigInteger
methods of the later class can be called onBigIntegerAlgebra
instances. The methods however will not return anBigIntegerAlgebra
instance but an instance of the super class as result. If needed, call theBigIntegerAlgebra(BigInteger)
constructor on the result to get aBigIntegerAlgebra
instance again. If this is considered inconvenient, wrapper methods for all relevant methods ofBigInteger
need to be implemented in the Algebra wrapper class.
-
-
Field Summary
-
Fields inherited from class java.math.BigInteger
ONE, TEN, TWO, ZERO
-
-
Constructor Summary
Constructors Constructor Description BigIntegerAlgebra(long value)
Constructs a new BigIntegerAlgebra object.BigIntegerAlgebra(String value)
Constructs a new BigIntegerAlgebra object.BigIntegerAlgebra(String value, int radix)
Constructs a new BigIntegerAlgebra object.BigIntegerAlgebra(BigInteger value)
Constructs a new BigIntegerAlgebra object from ajava.math.BigInteger
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BigIntegerAlgebra
add(BigInteger opnd)
Addsopnd
to this.BigIntegerAlgebra
div(BigInteger opnd)
Divides this byopnd
.BigIntegerAlgebra
mul(BigInteger opnd)
(Post)Multiplies this byopnd
.BigIntegerAlgebra
neg()
CallsBigInteger.negate()
.BigIntegerAlgebra
pow(int exponent)
Returns the power ofexponent
of this.BigIntegerAlgebra
remainder(BigInteger opnd)
Returns the remainder of this divided byopnd
.BigIntegerAlgebra
sub(BigInteger opnd)
Subtractsopnd
from this.-
Methods inherited from class java.math.BigInteger
abs, and, andNot, bitCount, bitLength, byteValueExact, clearBit, compareTo, divide, divideAndRemainder, doubleValue, equals, flipBit, floatValue, gcd, getLowestSetBit, hashCode, intValue, intValueExact, isProbablePrime, longValue, longValueExact, max, min, mod, modInverse, modPow, multiply, negate, nextProbablePrime, not, or, probablePrime, setBit, shiftLeft, shiftRight, shortValueExact, signum, sqrt, sqrtAndRemainder, subtract, testBit, toByteArray, toString, toString, valueOf, xor
-
Methods inherited from class java.lang.Number
byteValue, shortValue
-
-
-
-
Constructor Detail
-
BigIntegerAlgebra
public BigIntegerAlgebra(BigInteger value)
Constructs a new BigIntegerAlgebra object from ajava.math.BigInteger
.
-
BigIntegerAlgebra
public BigIntegerAlgebra(String value)
Constructs a new BigIntegerAlgebra object.
Callsjava.math.BigInteger(String)
but allows arbitrary' '
or'_'
characters invalue
to improve readability.
-
BigIntegerAlgebra
public BigIntegerAlgebra(String value, int radix)
Constructs a new BigIntegerAlgebra object.
Callsjava.math.BigInteger( value, radix )
but allows arbitrary' '
or'_'
characters invalue
.
-
BigIntegerAlgebra
public BigIntegerAlgebra(long value)
Constructs a new BigIntegerAlgebra object.
Required for mixed operations: int op BigInteger, BigInteger op int
-
-
Method Detail
-
neg
public BigIntegerAlgebra neg()
CallsBigInteger.negate()
.
-
add
public BigIntegerAlgebra add(BigInteger opnd)
- Overrides:
add
in classBigInteger
-
sub
public BigIntegerAlgebra sub(BigInteger opnd)
-
mul
public BigIntegerAlgebra mul(BigInteger opnd)
-
div
public BigIntegerAlgebra div(BigInteger opnd)
-
remainder
public BigIntegerAlgebra remainder(BigInteger opnd)
- Overrides:
remainder
in classBigInteger
-
pow
public BigIntegerAlgebra pow(int exponent)
- Overrides:
pow
in classBigInteger
-
-