|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Number
org.apfloat.Apcomplex
org.apfloat.Apfloat
org.apfloat.Aprational
org.apfloat.Apint
Arbitrary precision integer class.
In addition to the constructors, it is possible to create an apint
from an apfloat or aprational via the methods that round these
numbers to an integer value: Apfloat.floor()
, Apfloat.ceil()
,
and Apfloat.truncate()
.
Field Summary |
Fields inherited from class org.apfloat.Apcomplex |
DEFAULT, I, INFINITE, ONE, ZERO |
Constructor Summary | |
protected |
Apint()
Default constructor. |
|
Apint(BigInteger value)
Constructs an apint from a BigInteger . |
|
Apint(BigInteger value,
int radix)
Constructs an apint from a BigInteger using the specified radix. |
|
Apint(long value)
Constructs an apfloat from the specified long .
|
|
Apint(long value,
int radix)
Constructs an apfloat from the specified long
and radix. |
|
Apint(PushbackReader in)
Reads an apint from a stream using the default radix. |
|
Apint(PushbackReader in,
int radix)
Reads an apint from a stream using the specified radix. |
|
Apint(String value)
Constructs an apfloat from the specified string. |
|
Apint(String value,
int radix)
Constructs an apfloat from the specified string and radix. |
Method Summary | |
Apint |
add(Apint x)
Adds two apints. |
Apint |
ceil()
Ceiling function. |
int |
compareTo(Apfloat x)
Compare this apint to the specified apfloat. |
int |
compareTo(Apint x)
Compare this apint to the specified apint. |
int |
compareTo(Aprational x)
Compare this apint to the specified aprational. |
int |
compareTo(Object obj)
Compare this apint to the specified object. |
Apint |
denominator()
Denominator of this aprational. |
Apint |
divide(Apint x)
Divides two apints. |
boolean |
equals(Object obj)
Compares this object to the specified object. |
Apint |
floor()
Floor function. |
protected ApfloatImpl |
getImpl(long precision)
Returns an ApfloatImpl representing this apint up to the requested precision. |
int |
hashCode()
Returns a hash code for this apint. |
boolean |
isShort()
Returns if this apint is "short". |
Apint |
mod(Apint x)
Calculates the remainder when divided by an apint. |
Apint |
multiply(Apint x)
Multiplies two apints. |
Apint |
numerator()
Numerator of this aprational. |
int |
radix()
Radix of this apint. |
long |
scale()
Returns the scale of this apint. |
int |
signum()
Returns the signum function of this apint. |
Apint |
subtract(Apint x)
Subtracts two apints. |
String |
toString(boolean pretty)
Returns a string representation of this aprational. |
Apint |
truncate()
Truncates fractional part. |
void |
writeTo(Writer out,
boolean pretty)
Write a string representation of this aprational to a Writer . |
Methods inherited from class org.apfloat.Aprational |
add, divide, multiply, precision, subtract, toString, writeTo |
Methods inherited from class org.apfloat.Apfloat |
add, byteValue, divide, doubleValue, equalDigits, floatValue, imag, intValue, longValue, multiply, precision, real, shortValue, subtract |
Methods inherited from class org.apfloat.Apcomplex |
add, conj, divide, equalDigits, multiply, subtract |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
protected Apint()
public Apint(String value) throws NumberFormatException, ApfloatRuntimeException
value
- The string representing the number.
NumberFormatException
- In case the number is invalid.
ApfloatRuntimeException
public Apint(String value, int radix) throws NumberFormatException, ApfloatRuntimeException
value
- The string representing the number.radix
- The radix of the number.
NumberFormatException
- In case the number is invalid.
ApfloatRuntimeException
public Apint(long value) throws NumberFormatException, ApfloatRuntimeException
long
.
The default radix will be used.
value
- The value of the number.
NumberFormatException
- In case the number is invalid.
ApfloatRuntimeException
public Apint(long value, int radix) throws NumberFormatException, ApfloatRuntimeException
long
and radix.
value
- The value of the number.radix
- The radix of the number.
NumberFormatException
- In case the number is invalid.
ApfloatRuntimeException
public Apint(PushbackReader in) throws IOException, NumberFormatException, ApfloatRuntimeException
in
- The stream to read from
IOException
- If an I/O error occurs accessing the stream.
NumberFormatException
- If the number is not valid.
ApfloatRuntimeException
public Apint(PushbackReader in, int radix) throws IOException, NumberFormatException, ApfloatRuntimeException
in
- The stream to read fromradix
- The radix of the number.
IOException
- If an I/O error occurs accessing the stream.
NumberFormatException
- If the number is not valid.
ApfloatRuntimeException
public Apint(BigInteger value) throws NumberFormatException, ApfloatRuntimeException
BigInteger
. The default radix is used.
value
- The value of the number.
NumberFormatException
- If the default radix is not valid.
ApfloatRuntimeException
public Apint(BigInteger value, int radix) throws NumberFormatException, ApfloatRuntimeException
BigInteger
using the specified radix.
value
- The value of the number.radix
- The radix of the number.
NumberFormatException
- If the radix is not valid.
ApfloatRuntimeException
Method Detail |
public Apint numerator()
numerator
in class Aprational
this
.public Apint denominator()
denominator
in class Aprational
Apcomplex.ONE
.public int radix()
radix
in class Aprational
public long scale() throws ApfloatRuntimeException
Zero has a scale of -INFINITE
.
scale
in class Aprational
ApfloatRuntimeException
public int signum()
signum
in class Aprational
public boolean isShort() throws ApfloatRuntimeException
isShort
in class Aprational
true
if the apint is "short", false
if not.
ApfloatRuntimeException
Apfloat.isShort()
public Apint add(Apint x) throws ApfloatRuntimeException
x
- The number to be added to this number.
this + x
.
ApfloatRuntimeException
public Apint subtract(Apint x) throws ApfloatRuntimeException
x
- The number to be subtracted from this number.
this - x
.
ApfloatRuntimeException
public Apint multiply(Apint x) throws ApfloatRuntimeException
x
- The number to be multiplied by this number.
this * x
.
ApfloatRuntimeException
public Apint divide(Apint x) throws ArithmeticException, ApfloatRuntimeException
x
- The number by which this number is to be divided.
this / x
.
ArithmeticException
- In case the divisor is zero.
ApfloatRuntimeException
public Apint mod(Apint x) throws ApfloatRuntimeException
x
is zero, then zero is returned.
x
- The number that is used as the divisor in the remainder calculation.
this % x
.
ApfloatRuntimeException
ApfloatMath.fmod(Apfloat,Apfloat)
public Apint floor()
floor
in class Aprational
public Apint ceil()
ceil
in class Aprational
public Apint truncate()
truncate
in class Aprational
public int compareTo(Apint x) throws ApfloatRuntimeException
x
- Apint to which this apint is to be compared.
x
.
ApfloatRuntimeException
public int compareTo(Aprational x) throws ApfloatRuntimeException
compareTo
in class Aprational
x
- Aprational to which this apint is to be compared.
x
.
ApfloatRuntimeException
public int compareTo(Apfloat x) throws ApfloatRuntimeException
compareTo
in class Aprational
x
- Apfloat to which this apint is to be compared.
x
.
ApfloatRuntimeException
public int compareTo(Object obj) throws ClassCastException, ApfloatRuntimeException
compareTo
in interface Comparable
compareTo
in class Aprational
obj
- Object to which this apint is to be compared.
obj
.
ClassCastException
- If the specified object is not an apfloat.
ApfloatRuntimeException
public boolean equals(Object obj) throws ApfloatRuntimeException
Note: if two apfloats are compared where one number doesn't have enough
precise digits, the mantissa is assumed to contain zeros.
See Apfloat.compareTo(Apfloat)
.
equals
in class Aprational
obj
- The object to compare with.
true
if the objects are the same; false
otherwise.
ApfloatRuntimeException
public int hashCode()
hashCode
in class Aprational
public String toString(boolean pretty) throws ApfloatRuntimeException
toString
in class Aprational
pretty
- true
to use a fixed-point notation, false
to use an exponential notation.
ApfloatRuntimeException
public void writeTo(Writer out, boolean pretty) throws IOException, ApfloatRuntimeException
Writer
.
writeTo
in class Aprational
out
- The output Writer
.pretty
- true
to use a fixed-point notation, false
to use an exponential notation.
IOException
- In case of I/O error writing to the stream.
ApfloatRuntimeException
protected ApfloatImpl getImpl(long precision) throws ApfloatRuntimeException
ApfloatImpl
representing this apint up to the requested precision.
getImpl
in class Aprational
precision
- Precision of the ApfloatImpl
that is needed.
ApfloatImpl
representing this object to the requested precision.
ApfloatRuntimeException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |