Package org.apfloat.spi
Interface ApfloatImpl
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
DoubleApfloatImpl
,FloatApfloatImpl
,IntApfloatImpl
,LongApfloatImpl
Interface for apfloat implementations. An
ApfloatImpl
implements all of the
low-level functionality that is needed behind the high-level apfloat API.
A class implementing ApfloatImpl
is not required to accept any other ApfloatImpl
class as the argument than the same implementing class.
- Version:
- 1.7.0
- Author:
- Mikko Tommila
-
Method Summary
Modifier and TypeMethodDescriptionabsCeil()
Returns thisApfloatImpl
rounded away from zero.absFloor()
Returns thisApfloatImpl
rounded towards zero.addOrSubtract
(ApfloatImpl x, boolean subtract) Add or subtract anApfloatImpl
to this object.int
Compare thisApfloatImpl
and another number.Divide thisApfloatImpl
by anApfloatImpl
that is "short".double
Returns the value of the this number as adouble
.long
The number of equal digits in thisApfloatImpl
and another number.frac()
Returns the fractional part of thisApfloatImpl
.int
hashCode()
Returns the hash code for thisApfloatImpl
.boolean
isOne()
Tests if this number is equal to 1.boolean
isShort()
Returns if thisApfloatImpl
is "short".long
Returns the value of the this number as along
.Multiply this object by anApfloatImpl
.negate()
Returns thisApfloatImpl
negated.long
Returns the precision of thisApfloatImpl
.precision
(long precision) Returns thisApfloatImpl
with the specified precision.int
radix()
Returns the radix of thisApfloatImpl
.long
scale()
Returns the scale of thisApfloatImpl
.int
signum()
Returns the signum of thisApfloatImpl
.long
size()
Returns the size of the mantissa of thisApfloatImpl
.toString
(boolean pretty) Convert thisApfloatImpl
toString
.void
Print thisApfloatImpl
to a stream.
-
Method Details
-
addOrSubtract
Add or subtract anApfloatImpl
to this object.- Parameters:
x
- The number to be added or subtracted to thisApfloatImpl
.subtract
-true
if the numbers are to be subtracted,false
if added.- Returns:
this + x
orthis - x
depending on thesubtract
argument.- Throws:
ApfloatRuntimeException
-
multiply
Multiply this object by anApfloatImpl
.- Parameters:
x
- The number to be multiplied by thisApfloatImpl
.- Returns:
this * x
.- Throws:
ApfloatRuntimeException
-
isShort
Returns if thisApfloatImpl
is "short". TypicallyApfloatImpl
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.
- Returns:
true
if theApfloatImpl
is "short",false
if not.- Throws:
ApfloatRuntimeException
- See Also:
-
divideShort
Divide thisApfloatImpl
by anApfloatImpl
that is "short".- Parameters:
x
- The number by which thisApfloatImpl
is to be divided.- Returns:
this / x
.- Throws:
ApfloatRuntimeException
-
absFloor
Returns thisApfloatImpl
rounded towards zero.- Returns:
- This
ApfloatImpl
rounded towards zero. - Throws:
ApfloatRuntimeException
-
absCeil
Returns thisApfloatImpl
rounded away from zero.- Returns:
- This
ApfloatImpl
rounded away from zero. - Throws:
ApfloatRuntimeException
-
frac
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
Returns the size of the mantissa of thisApfloatImpl
.- Returns:
- The size of the mantissa of this
ApfloatImpl
. - Throws:
ApfloatRuntimeException
- Since:
- 1.2
-
precision
Returns thisApfloatImpl
with the specified precision.- Parameters:
precision
- The precision.- Returns:
- This
ApfloatImpl
with the specified precision. - Throws:
ApfloatRuntimeException
-
scale
Returns the scale of thisApfloatImpl
.- Returns:
- The scale of this
ApfloatImpl
. - Throws:
ApfloatRuntimeException
- See Also:
-
signum
int signum()Returns the signum of thisApfloatImpl
.- Returns:
- The signum of this
ApfloatImpl
. - See Also:
-
negate
Returns thisApfloatImpl
negated.- 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_INFINITY
is returned.If the number is less than
Double.MIN_VALUE
, thenDouble.NEGATIVE_INFINITY
is 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_VALUE
is returned.If the number is less than
Long.MIN_VALUE
, thenLong.MIN_VALUE
is returned.- Returns:
- The numeric value represented by this object after conversion to type
long
.
-
isOne
Tests if this number is equal to 1.- Returns:
true
if this number is equal to one, otherwisefalse
.- Throws:
ApfloatRuntimeException
-
equalDigits
The number of equal digits in thisApfloatImpl
and another number.- Parameters:
x
- The number to compare with.- Returns:
- The number of equal digits in this
ApfloatImpl
andx
. - Throws:
ApfloatRuntimeException
- See Also:
-
compareTo
Compare thisApfloatImpl
and 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:
-
hashCode
-
toString
Convert thisApfloatImpl
toString
.- Parameters:
pretty
- Flag for formatting.- Returns:
- String representation of this
ApfloatImpl
. - Throws:
ApfloatRuntimeException
- See Also:
-
writeTo
Print thisApfloatImpl
to a stream.- Parameters:
out
- The stream to write to.pretty
- Flag for formatting.- Throws:
IOException
- In case of I/O error writing to the stream.ApfloatRuntimeException
- See Also:
-