Package org.apfloat.spi
Interface ApfloatImpl
-
- All Superinterfaces:
java.io.Serializable
- All Known Implementing Classes:
DoubleApfloatImpl,FloatApfloatImpl,IntApfloatImpl,LongApfloatImpl
public interface ApfloatImpl extends java.io.SerializableInterface for apfloat implementations. AnApfloatImplimplements all of the low-level functionality that is needed behind the high-level apfloat API.A class implementing
ApfloatImplis not required to accept any otherApfloatImplclass as the argument than the same implementing class.- Version:
- 1.7.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ApfloatImplabsCeil()Returns thisApfloatImplrounded away from zero.ApfloatImplabsFloor()Returns thisApfloatImplrounded towards zero.ApfloatImpladdOrSubtract(ApfloatImpl x, boolean subtract)Add or subtract anApfloatImplto this object.intcompareTo(ApfloatImpl x)Compare thisApfloatImpland another number.ApfloatImpldivideShort(ApfloatImpl x)Divide thisApfloatImplby anApfloatImplthat is "short".doubledoubleValue()Returns the value of the this number as adouble.longequalDigits(ApfloatImpl x)The number of equal digits in thisApfloatImpland another number.ApfloatImplfrac()Returns the fractional part of thisApfloatImpl.inthashCode()Returns the hash code for thisApfloatImpl.booleanisOne()Tests if this number is equal to 1.booleanisShort()Returns if thisApfloatImplis "short".longlongValue()Returns the value of the this number as along.ApfloatImplmultiply(ApfloatImpl x)Multiply this object by anApfloatImpl.ApfloatImplnegate()Returns thisApfloatImplnegated.longprecision()Returns the precision of thisApfloatImpl.ApfloatImplprecision(long precision)Returns thisApfloatImplwith the specified precision.intradix()Returns the radix of thisApfloatImpl.longscale()Returns the scale of thisApfloatImpl.intsignum()Returns the signum of thisApfloatImpl.longsize()Returns the size of the mantissa of thisApfloatImpl.java.lang.StringtoString(boolean pretty)Convert thisApfloatImpltoString.voidwriteTo(java.io.Writer out, boolean pretty)Print thisApfloatImplto a stream.
-
-
-
Method Detail
-
addOrSubtract
ApfloatImpl addOrSubtract(ApfloatImpl x, boolean subtract) throws ApfloatRuntimeException
Add or subtract anApfloatImplto this object.- Parameters:
x- The number to be added or subtracted to thisApfloatImpl.subtract-trueif the numbers are to be subtracted,falseif added.- Returns:
this + xorthis - xdepending on thesubtractargument.- Throws:
ApfloatRuntimeException
-
multiply
ApfloatImpl multiply(ApfloatImpl x) throws ApfloatRuntimeException
Multiply this object by anApfloatImpl.- Parameters:
x- The number to be multiplied by thisApfloatImpl.- Returns:
this * x.- Throws:
ApfloatRuntimeException
-
isShort
boolean isShort() throws ApfloatRuntimeExceptionReturns if thisApfloatImplis "short". TypicallyApfloatImplis "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.
- Returns:
trueif theApfloatImplis "short",falseif not.- Throws:
ApfloatRuntimeException- See Also:
Apfloat.isShort()
-
divideShort
ApfloatImpl divideShort(ApfloatImpl x) throws ApfloatRuntimeException
Divide thisApfloatImplby anApfloatImplthat is "short".- Parameters:
x- The number by which thisApfloatImplis to be divided.- Returns:
this / x.- Throws:
ApfloatRuntimeException
-
absFloor
ApfloatImpl absFloor() throws ApfloatRuntimeException
Returns thisApfloatImplrounded towards zero.- Returns:
- This
ApfloatImplrounded towards zero. - Throws:
ApfloatRuntimeException
-
absCeil
ApfloatImpl absCeil() throws ApfloatRuntimeException
Returns thisApfloatImplrounded away from zero.- Returns:
- This
ApfloatImplrounded away from zero. - Throws:
ApfloatRuntimeException
-
frac
ApfloatImpl frac() throws ApfloatRuntimeException
Returns the fractional part of thisApfloatImpl.- Returns:
- The fractional part of this
ApfloatImpl. - Throws:
ApfloatRuntimeException- Since:
- 1.7.0
-
radix
int radix()
Returns the radix of thisApfloatImpl.- Returns:
- The radix of this
ApfloatImpl.
-
precision
long precision()
Returns the precision of thisApfloatImpl.- Returns:
- The precision of this
ApfloatImpl.
-
size
long size() throws ApfloatRuntimeException
Returns the size of the mantissa of thisApfloatImpl.- Returns:
- The size of the mantissa of this
ApfloatImpl. - Throws:
ApfloatRuntimeException- Since:
- 1.2
-
precision
ApfloatImpl precision(long precision) throws ApfloatRuntimeException
Returns thisApfloatImplwith the specified precision.- Parameters:
precision- The precision.- Returns:
- This
ApfloatImplwith the specified precision. - Throws:
ApfloatRuntimeException
-
scale
long scale() throws ApfloatRuntimeExceptionReturns the scale of thisApfloatImpl.- Returns:
- The scale of this
ApfloatImpl. - Throws:
ApfloatRuntimeException- See Also:
Apfloat.scale()
-
signum
int signum()
Returns the signum of thisApfloatImpl.- Returns:
- The signum of this
ApfloatImpl. - See Also:
Apfloat.signum()
-
negate
ApfloatImpl negate() throws ApfloatRuntimeException
Returns thisApfloatImplnegated.- Returns:
-this.- Throws:
ApfloatRuntimeException
-
doubleValue
double doubleValue()
Returns the value of the this number as adouble. If the number is greater thanDouble.MAX_VALUE, thenDouble.POSITIVE_INFINITYis returned.If the number is less than
Double.MIN_VALUE, thenDouble.NEGATIVE_INFINITYis returned.If the number is very small in magnitude, underflow may happen and zero is returned.
- Returns:
- The numeric value represented by this object after conversion to type
double.
-
longValue
long longValue()
Returns the value of the this number as along. The fractional part is truncated towards zero.If the number is greater than
Long.MAX_VALUE, thenLong.MAX_VALUEis returned.If the number is less than
Long.MIN_VALUE, thenLong.MIN_VALUEis returned.- Returns:
- The numeric value represented by this object after conversion to type
long.
-
isOne
boolean isOne() throws ApfloatRuntimeExceptionTests if this number is equal to 1.- Returns:
trueif this number is equal to one, otherwisefalse.- Throws:
ApfloatRuntimeException
-
equalDigits
long equalDigits(ApfloatImpl x) throws ApfloatRuntimeException
The number of equal digits in thisApfloatImpland another number.- Parameters:
x- The number to compare with.- Returns:
- The number of equal digits in this
ApfloatImplandx. - Throws:
ApfloatRuntimeException- See Also:
Apfloat.equalDigits(org.apfloat.Apfloat)
-
compareTo
int compareTo(ApfloatImpl x) throws ApfloatRuntimeException
Compare thisApfloatImpland another number.- Parameters:
x- The number to compare with.- Returns:
- Zero, less than zero or greater than zero depending on the result of the comparison.
- Throws:
ApfloatRuntimeException- See Also:
Apfloat.compareTo(org.apfloat.Apfloat)
-
hashCode
int hashCode()
Returns the hash code for thisApfloatImpl.- Overrides:
hashCodein classjava.lang.Object- Returns:
- The hash code for this
ApfloatImpl.
-
toString
java.lang.String toString(boolean pretty) throws ApfloatRuntimeExceptionConvert thisApfloatImpltoString.- Parameters:
pretty- Flag for formatting.- Returns:
- String representation of this
ApfloatImpl. - Throws:
ApfloatRuntimeException- See Also:
Apfloat.toString(boolean)
-
writeTo
void writeTo(java.io.Writer out, boolean pretty) throws java.io.IOException, ApfloatRuntimeExceptionPrint thisApfloatImplto a stream.- Parameters:
out- The stream to write to.pretty- Flag for formatting.- Throws:
java.io.IOException- In case of I/O error writing to the stream.ApfloatRuntimeException- See Also:
Apfloat.writeTo(Writer,boolean)
-
-