|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.znerd.math.RoundingMode
Rounding mode. This is an abstract base class for actual rounding mode implementations.
Concrete subclasses must implement
roundImpl(RealNumber,int,int,int)
.
Constructor Summary | |
protected |
RoundingMode(String name,
boolean consistent)
Constructs a new RoundingMode with the specified name. |
Method Summary | |
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. |
String |
toString()
Returns a textual presentation of this object. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
protected RoundingMode(String name, boolean consistent) throws 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.Method Detail |
public final boolean round(RealNumber number, int radix, int digit) throws 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.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 String getName()
null
.public final String toString()
null
.public final boolean isConsistent()
true
if this rounding mode always rounds the same way
when passed the same arguments.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |