public class Apint extends Aprational
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().
ApintMath,
Serialized Form| Modifier | Constructor and Description |
|---|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
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.
|
void |
formatTo(Formatter formatter,
int flags,
int width,
int precision)
Formats the object using the provided formatter.
|
Apint |
frac()
Returns the fractional part.
|
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 |
negate()
Negative value.
|
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.
|
long |
size()
Returns the size of this apint.
|
Apint |
subtract(Apint x)
Subtracts two apints.
|
BigInteger |
toBigInteger()
Converts this apint to Java's
BigInteger. |
Apint |
toRadix(int radix)
Convert this apint to the specified radix.
|
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. |
add, divide, mod, multiply, precision, preferCompare, subtract, toString, writeToadd, byteValue, divide, doubleValue, equalDigits, floatValue, imag, intValue, longValue, mod, multiply, precision, real, shortValue, subtractprotected Apint()
public Apint(String value) throws NumberFormatException, ApfloatRuntimeException
value - The string representing the number.NumberFormatException - In case the number is invalid.ApfloatRuntimeExceptionpublic 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.ApfloatRuntimeExceptionpublic 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.ApfloatRuntimeExceptionpublic 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.ApfloatRuntimeExceptionpublic Apint(PushbackReader in) throws IOException, NumberFormatException, ApfloatRuntimeException
in - The stream to read fromIOException - If an I/O error occurs accessing the stream.NumberFormatException - If the number is not valid.ApfloatRuntimeExceptionpublic 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.ApfloatRuntimeExceptionpublic 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.ApfloatRuntimeExceptionpublic 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.ApfloatRuntimeExceptionpublic Apint numerator()
numerator in class Aprationalthis.public Apint denominator()
denominator in class AprationalApcomplex.ONE.public int radix()
radix in class Aprationalpublic long scale()
throws ApfloatRuntimeException
Zero has a scale of -INFINITE.
scale in class AprationalApfloatRuntimeExceptionApfloat.scale()public long size()
throws ApfloatRuntimeException
Zero has a size of 0.
size in class AprationalApfloatRuntimeExceptionApfloat.size()public int signum()
signum in class Aprationalpublic boolean isShort()
throws ApfloatRuntimeException
isShort in class Aprationaltrue if the apint is "short", false if not.ApfloatRuntimeExceptionApfloat.isShort()public Apint negate() throws ApfloatRuntimeException
negate in class Aprational-this.ApfloatRuntimeExceptionpublic Apint add(Apint x) throws ApfloatRuntimeException
x - The number to be added to this number.this + x.ApfloatRuntimeExceptionpublic Apint subtract(Apint x) throws ApfloatRuntimeException
x - The number to be subtracted from this number.this - x.ApfloatRuntimeExceptionpublic Apint multiply(Apint x) throws ApfloatRuntimeException
x - The number to be multiplied by this number.this * x.ApfloatRuntimeExceptionpublic 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.ApfloatRuntimeExceptionpublic 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.ApfloatRuntimeExceptionApfloatMath.fmod(Apfloat,Apfloat)public Apint floor()
floor in class Aprationalpublic Apint ceil()
ceil in class Aprationalpublic Apint truncate()
truncate in class Aprationalpublic Apint frac() throws ApfloatRuntimeException
frac in class AprationalApfloatRuntimeExceptionpublic BigInteger toBigInteger() throws IllegalArgumentException
BigInteger.
This method can be greatly faster than converting to String
and then to BigInteger.BigInteger.IllegalArgumentException - If this number is too big to fit in a BigInteger.public Apint toRadix(int radix) throws NumberFormatException, ApfloatRuntimeException
toRadix in class Aprationalradix - The radix.NumberFormatException - If the radix is invalid.ApfloatRuntimeExceptionpublic int compareTo(Apint x)
x - Apint to which this apint is to be compared.x.public int compareTo(Aprational x)
compareTo in class Aprationalx - Aprational to which this apint is to be compared.x.public int compareTo(Apfloat x)
compareTo in interface Comparable<Apfloat>compareTo in class Aprationalx - Apfloat to which this apint is to be compared.x.public boolean equals(Object obj)
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 Aprationalobj - The object to compare with.true if the objects are the same; false otherwise.public int hashCode()
hashCode in class Aprationalpublic String toString(boolean pretty) throws ApfloatRuntimeException
toString in class Aprationalpretty - true to use a fixed-point notation, false to use an exponential notation.ApfloatRuntimeExceptionpublic void writeTo(Writer out, boolean pretty) throws IOException, ApfloatRuntimeException
Writer.writeTo in class Aprationalout - 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.ApfloatRuntimeExceptionpublic void formatTo(Formatter formatter, int flags, int width, int precision)
AprationalformatTo in interface FormattableformatTo in class Aprationalformatter - The formatter.flags - The flags to modify the output format.width - The minimum number of characters to be written to the output, or -1 for no minimum.precision - The maximum number of characters to be written to the output, or -1 for no maximum.Apfloat.formatTo(Formatter,int,int,int)protected ApfloatImpl getImpl(long precision) throws ApfloatRuntimeException
ApfloatImpl representing this apint up to the requested precision.getImpl in class Aprationalprecision - Precision of the ApfloatImpl that is needed.ApfloatImpl representing this object to the requested precision.ApfloatRuntimeExceptionCopyright © 2024. All rights reserved.