public abstract class RoundingMode
extends java.lang.Object
roundImpl(RealNumber,int,int,int)
.Modifier | Constructor and Description |
---|---|
protected |
RoundingMode(java.lang.String name,
boolean consistent)
Constructs a new
RoundingMode with the specified name. |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getName()
Returns a short, human-presentable, description of this rounding mode.
|
boolean |
isConsistent()
Indicates if this rounding mode is consistent.
|
boolean |
round(RealNumber number,
int radix,
int digit)
Rounds the specified digit for a number in the specified base.
|
protected abstract boolean |
roundImpl(RealNumber number,
int sign,
int radix,
int digit)
Actually rounds the specified digit for a number in the specified base.
|
java.lang.String |
toString()
Returns a textual presentation of this object.
|
protected RoundingMode(java.lang.String name, boolean consistent) throws java.lang.IllegalArgumentException
RoundingMode
with the specified name. The
name will be returned by getName()
.name
- the name for the rounding mode, not null
.consistent
- true
if this rounding mode always rounds in the same
direction when passed the same arguments.java.lang.IllegalArgumentException
- if name == null
.public final boolean round(RealNumber number, int radix, int digit) throws java.lang.IllegalArgumentException
false
is returned.number
- the number that is being rounded, not null
.radix
- the radix (or base) for the digit, at least 2, at most
RealNumber.MAXIMUM_RADIX
.digit
- the digit of which should be determined whether it should be rounded
up or down, it should be at least 0, and less than the radix.true
if the concerned number should be rounded up, away
from zero; false
if it should be rounded down, towards
zero.java.lang.IllegalArgumentException
- if number == null
|| radix < 2
|| radix > RealNumber.MAXIMUM_RADIX
|| digit < 0
|| digit >= radix
.protected abstract boolean roundImpl(RealNumber number, int sign, int radix, int digit)
round(RealNumber,int,int)
.number
- the number that is being rounded, guaranteed not to be
null
and not to be zero.sign
- the sign, either -1 or 1.radix
- the radix (or base) for the digit, guaranteed to be at least 2 and at
most RealNumber.MAXIMUM_RADIX
.digit
- the digit of which should be determined whether it should be rounded
up or down, guaranteed to be at least 0, and less than the radix.true
if the concerned number should be rounded up, away
from zero; false
if it should be rounded down, towards
zero.public final java.lang.String getName()
null
.public final java.lang.String toString()
toString
in class java.lang.Object
null
.public final boolean isConsistent()
true
if this rounding mode always rounds the same way
when passed the same arguments.