|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.clazzes.optional.lang.BigInt
public final class BigInt
A variable length integer class.
Constructor Summary | |
---|---|
BigInt(int i)
|
|
BigInt(int sign,
byte[] raw)
Create a big integer from a MSB raw value. |
|
BigInt(int sign,
int[] v)
Construct a string from an internal representation. |
|
BigInt(long i)
|
Method Summary | |
---|---|
BigInt |
add(BigInt a)
Add a to this and return the result. |
int |
compareTo(BigInt a)
Compare this number with a by taking signs into account. |
int |
compareTo(int a)
Compare this number with a by taking signs into account. |
boolean |
equals(java.lang.Object o)
|
byte[] |
getASN1()
Convert this BigInt to an ASN1 MSB first integer representation. |
int |
getByteLength()
|
int |
getHighestBit()
Calculate the highest bit set in the magnitude of this number. |
byte[] |
getMsbMagnitude()
|
int |
getSign()
|
static BigInt |
hexValueOf(java.lang.String s)
Parse the given hexadecimal string and return the resulting BigInt. |
BigInt |
mod(BigInt b)
Calculate this modulo b . |
BigInt |
mul(BigInt a)
Multiply a and this and return the result. |
BigInt |
mulMod(BigInt a,
BigInt b)
Multiply a and this and return the result modulo
b . |
BigInt |
powMod(BigInt n,
BigInt b)
Calculate this^n and return the result modulo
b . |
BigInt |
powMod(int n,
BigInt b)
Calculate this^n and return the result modulo
b . |
static BigInt |
readDataInstance(java.io.DataInput in)
Read a positive BigInt from the given data input using a two byte length prefix. |
BigInt |
sub(BigInt a)
Subtract a from this and return the result. |
java.lang.String |
toHexString()
Convert a BigInt to a hexadecimal string. |
java.lang.String |
toJavaInitializer(java.lang.String identifier)
Return a jString, which may be inserted in JAVA source code to initialize a static instance in the form static final BigInt identifier = new BigInt(sign, new int[] { 0xdeabbeef,0xadbedba,.... }); |
java.lang.String |
toString()
|
static BigInt |
valueOf(byte[] asn1)
Parse an ASN.1 INTEGER representation. |
static BigInt |
valueOf(java.lang.String s)
Parse the given decimal string and return the resulting BigInt. |
void |
writeData(java.io.DataOutput out)
Write the MSB magnitude of this BigInt to the given data output using a two byte length prefix. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public BigInt(int sign, int[] v)
sign
- The sign of the returned instance. Should be 1
or -1
.v
- The internal integer array starting with the least significant 32 bits.toJavaInitializer(String)
public BigInt(int i)
public BigInt(long i)
public BigInt(int sign, byte[] raw)
sign
- If negative, this number is negative.raw
- An array of raw bytes starting with the most significant one.Method Detail |
---|
public static BigInt valueOf(java.lang.String s)
s
- A string consisting of an optional -
sign followed
by a sequence of digits 0...9
.
public static BigInt hexValueOf(java.lang.String s)
s
- A string consisting of an optional -
sign followed
by a sequence of digits 0...9,A...F
.
public static BigInt valueOf(byte[] asn1)
asn1
- The content octets of an ASN.1 INTEGER.
public static BigInt readDataInstance(java.io.DataInput in) throws java.io.IOException
in
- The input stream to read from.
java.io.IOException
public void writeData(java.io.DataOutput out) throws java.io.IOException
writeData
in interface DataCodeable
out
- The output stream to write to.
java.io.IOException
- Upon write errors.public int getByteLength()
getMsbMagnitude()
in bytes.public byte[] getMsbMagnitude()
public byte[] getASN1()
public java.lang.String toHexString()
public int getSign()
public int compareTo(BigInt a)
a
by taking signs into account.
a
- the number to compare this instance with.
-1,0
or 1
if this number
is less than, equal to or greater than a
.public int compareTo(int a)
a
by taking signs into account.
a
- the number to compare this instance with.
-1,0
or 1
if this number
is less than, equal to or greater than a
.public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toJavaInitializer(java.lang.String identifier)
static final BigInt identifier = new BigInt(sign, new int[] { 0xdeabbeef,0xadbedba,.... });
identifier
- The name of the identifier to use.public BigInt add(BigInt a)
a
to this
and return the result.
a
- The number to add.
this+a
.public BigInt sub(BigInt a)
a
from this
and return the result.
a
- The number to subtract.
this-a
.public BigInt mul(BigInt a)
a
and this
and return the result.
a
- The number to multiply.
this*a
.public int getHighestBit()
1
is counted as bit 0
,
the bit with value 1<<x
is counted as bit x
.
For a value of zero, -1
is returned.
0
at the least significant bit.public BigInt mod(BigInt b)
this
modulo b
.
b
-
this % b
.public BigInt mulMod(BigInt a, BigInt b)
a
and this
and return the result modulo
b
.
a
- The number to multiply.b
- The modulus.
(this*a)%b
.public BigInt powMod(int n, BigInt b)
this^n
and return the result modulo
b
.
n
- The exponent.b
- The modulus.
(this^n)%b
.public BigInt powMod(BigInt n, BigInt b)
this^n
and return the result modulo
b
.
n
- The exponent.b
- The modulus.
(this^n)%b
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |