|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apfloat.internal.LongBaseMath
org.apfloat.internal.LongApfloatImpl
public final class LongApfloatImpl
Immutable apfloat implementation class for the
long data element type.
The associated DataStorage is assumed to be immutable also.
This way performance can be improved by sharing the data storage between
different ApfloatImpl's and by only varying the
ApfloatImpl specific fields, like sign, precision and exponent.
This implementation doesn't necessarily store any extra digits for added precision, so the last digit of any operation may be inaccurate.
| Constructor Summary | |
|---|---|
LongApfloatImpl(double value,
long precision,
int radix)
Create a new LongApfloatImpl instance from a double. |
|
LongApfloatImpl(long value,
long precision,
int radix)
Create a new LongApfloatImpl instance from a long. |
|
LongApfloatImpl(PushbackReader in,
long precision,
int radix,
boolean isInteger)
Create a new LongApfloatImpl instance reading from a stream. |
|
LongApfloatImpl(String value,
long precision,
int radix,
boolean isInteger)
Create a new LongApfloatImpl instance from a String. |
|
| Method Summary | |
|---|---|
ApfloatImpl |
absCeil()
Returns this ApfloatImpl rounded away from zero. |
ApfloatImpl |
absFloor()
Returns this ApfloatImpl rounded towards zero. |
ApfloatImpl |
addOrSubtract(ApfloatImpl x,
boolean subtract)
Add or subtract an ApfloatImpl to this object. |
int |
compareTo(ApfloatImpl x)
Compare this ApfloatImpl and another number. |
ApfloatImpl |
divideShort(ApfloatImpl x)
Divide this ApfloatImpl by an ApfloatImpl that is "short". |
double |
doubleValue()
Returns the value of the this number as a double. |
long |
equalDigits(ApfloatImpl x)
The number of equal digits in this ApfloatImpl and another number. |
boolean |
equals(Object obj)
Compares this object to the specified object. |
int |
hashCode()
Returns the hash code for this ApfloatImpl. |
boolean |
isOne()
Tests if this number is equal to 1. |
boolean |
isShort()
Returns if this ApfloatImpl is "short". |
long |
longValue()
Returns the value of the this number as a long. |
ApfloatImpl |
multiply(ApfloatImpl x)
Multiply this object by an ApfloatImpl. |
ApfloatImpl |
negate()
Returns this ApfloatImpl negated. |
long |
precision()
Returns the precision of this ApfloatImpl. |
ApfloatImpl |
precision(long precision)
Returns this ApfloatImpl with the specified precision. |
int |
radix()
Returns the radix of this ApfloatImpl. |
long |
scale()
Returns the scale of this ApfloatImpl. |
int |
signum()
Returns the signum of this ApfloatImpl. |
long |
size()
Returns the size of the mantissa of this ApfloatImpl. |
String |
toString(boolean pretty)
Convert this ApfloatImpl to String. |
void |
writeTo(Writer out,
boolean pretty)
Print this ApfloatImpl to a stream. |
| Methods inherited from class org.apfloat.internal.LongBaseMath |
|---|
baseAdd, baseDivide, baseMultiplyAdd, baseSubtract |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public LongApfloatImpl(String value,
long precision,
int radix,
boolean isInteger)
throws NumberFormatException,
ApfloatRuntimeException
LongApfloatImpl instance from a String.
value - The string to be parsed to a number.precision - The precision of the number (in digits of the radix).radix - The radix in which the number is created.isInteger - Specifies if the number to be parsed from the string is to be treated as an integer or not.
NumberFormatException - If the number is not valid.
ApfloatRuntimeException
public LongApfloatImpl(long value,
long precision,
int radix)
throws NumberFormatException,
ApfloatRuntimeException
LongApfloatImpl instance from a long.
value - The value of the number.precision - The precision of the number (in digits of the radix).radix - The radix in which the number is created.
NumberFormatException - If the number is not valid.
ApfloatRuntimeException
public LongApfloatImpl(double value,
long precision,
int radix)
throws NumberFormatException,
ApfloatRuntimeException
LongApfloatImpl instance from a double.
value - The value of the number.precision - The precision of the number (in digits of the radix).radix - The radix in which the number is created.
NumberFormatException - If the number is not valid.
ApfloatRuntimeException
public LongApfloatImpl(PushbackReader in,
long precision,
int radix,
boolean isInteger)
throws IOException,
NumberFormatException,
ApfloatRuntimeException
LongApfloatImpl instance reading from a stream.
Implementation note: this constructor calls the in stream's
single-character read() method. If the underlying stream doesn't
explicitly implement this method in some efficient way, but simply inherits it
from the Reader base class, performance will suffer as the default
Reader method creates a new char[1] on every call to
read().
in - The stream to read from.precision - The precision of the number (in digits of the radix).radix - The radix in which the number is created.isInteger - Specifies if the number to be parsed from the stream is to be treated as an integer or not.
IOException - If an I/O error occurs accessing the stream.
NumberFormatException - If the number is not valid.
ApfloatRuntimeException| Method Detail |
|---|
public ApfloatImpl addOrSubtract(ApfloatImpl x,
boolean subtract)
throws ApfloatRuntimeException
ApfloatImplApfloatImpl to this object.
addOrSubtract in interface ApfloatImplx - The number to be added or subtracted to this ApfloatImpl.subtract - true if the numbers are to be subtracted, false if added.
this + x or this - x depending on the subtract argument.
ApfloatRuntimeException
public ApfloatImpl multiply(ApfloatImpl x)
throws ApfloatRuntimeException
ApfloatImplApfloatImpl.
multiply in interface ApfloatImplx - The number to be multiplied by this ApfloatImpl.
this * x.
ApfloatRuntimeException
public boolean isShort()
throws ApfloatRuntimeException
ApfloatImplApfloatImpl is "short". Typically ApfloatImpl
is "short" if its mantissa fits in one machine word. If the apfloat is "short",
some algorithms can be performed faster.The return value of this method is highly implementation dependent.
isShort in interface ApfloatImpltrue if the ApfloatImpl is "short", false if not.
ApfloatRuntimeExceptionApfloat.isShort()
public ApfloatImpl divideShort(ApfloatImpl x)
throws ApfloatRuntimeException
ApfloatImplApfloatImpl by an ApfloatImpl that is "short".
divideShort in interface ApfloatImplx - The number by which this ApfloatImpl is to be divided.
this / x.
ApfloatRuntimeException
public ApfloatImpl absFloor()
throws ApfloatRuntimeException
ApfloatImplApfloatImpl rounded towards zero.
absFloor in interface ApfloatImplApfloatImpl rounded towards zero.
ApfloatRuntimeException
public ApfloatImpl absCeil()
throws ApfloatRuntimeException
ApfloatImplApfloatImpl rounded away from zero.
absCeil in interface ApfloatImplApfloatImpl rounded away from zero.
ApfloatRuntimeExceptionpublic int radix()
ApfloatImplApfloatImpl.
radix in interface ApfloatImplApfloatImpl.public long precision()
ApfloatImplApfloatImpl.
precision in interface ApfloatImplApfloatImpl.
public long size()
throws ApfloatRuntimeException
ApfloatImplApfloatImpl.
size in interface ApfloatImplApfloatImpl.
ApfloatRuntimeExceptionpublic ApfloatImpl precision(long precision)
ApfloatImplApfloatImpl with the specified precision.
precision in interface ApfloatImplprecision - The precision.
ApfloatImpl with the specified precision.
public long scale()
throws ApfloatRuntimeException
ApfloatImplApfloatImpl.
scale in interface ApfloatImplApfloatImpl.
ApfloatRuntimeExceptionApfloat.scale()public int signum()
ApfloatImplApfloatImpl.
signum in interface ApfloatImplApfloatImpl.Apfloat.signum()
public ApfloatImpl negate()
throws ApfloatRuntimeException
ApfloatImplApfloatImpl negated.
negate in interface ApfloatImpl-this.
ApfloatRuntimeExceptionpublic double doubleValue()
ApfloatImpldouble.
If the number is greater than Double.MAX_VALUE,
then Double.POSITIVE_INFINITY is returned.
If the number is less than Double.MIN_VALUE,
then Double.NEGATIVE_INFINITY is returned.
If the number is very small in magnitude, underflow may happen and zero is returned.
doubleValue in interface ApfloatImpldouble.public long longValue()
ApfloatImpllong.
The fractional part is truncated towards zero.
If the number is greater than Long.MAX_VALUE,
then Long.MAX_VALUE is returned.
If the number is less than Long.MIN_VALUE,
then Long.MIN_VALUE is returned.
longValue in interface ApfloatImpllong.
public boolean isOne()
throws ApfloatRuntimeException
ApfloatImpl
isOne in interface ApfloatImpltrue if this number is equal to one, otherwise false.
ApfloatRuntimeException
public long equalDigits(ApfloatImpl x)
throws ApfloatRuntimeException
ApfloatImplApfloatImpl and another number.
equalDigits in interface ApfloatImplx - The number to compare with.
ApfloatImpl and x.
ApfloatRuntimeExceptionApfloat.equalDigits(org.apfloat.Apfloat)
public int compareTo(ApfloatImpl x)
throws ApfloatRuntimeException
ApfloatImplApfloatImpl and another number.
compareTo in interface ApfloatImplx - The number to compare with.
ApfloatRuntimeExceptionApfloat.compareTo(org.apfloat.Apfloat)public boolean equals(Object obj)
equals in class Objectobj - The object to compare with.
true if the objects are equal; false otherwise.public int hashCode()
ApfloatImplApfloatImpl.
hashCode in interface ApfloatImplhashCode in class ObjectApfloatImpl.
public String toString(boolean pretty)
throws ApfloatRuntimeException
ApfloatImplApfloatImpl to String.
toString in interface ApfloatImplpretty - Flag for formatting.
ApfloatImpl.
ApfloatRuntimeExceptionApfloat.toString(boolean)
public void writeTo(Writer out,
boolean pretty)
throws IOException,
ApfloatRuntimeException
ApfloatImplApfloatImpl to a stream.
writeTo in interface ApfloatImplout - The stream to write to.pretty - Flag for formatting.
IOException - In case of I/O error writing to the stream.
ApfloatRuntimeExceptionApfloat.writeTo(Writer,boolean)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||