public final class Multipliable18f extends Object
Multipliable18f
encapsulates a Decimal of scale 18 and facilitates
exact typed multiplication. The multipliable object acts as first factor in the multiplication
and provides a set of overloaded methods for different scales. Each one of those methods
delivers a different result scale which represents the appropriate scale for the product of
an exact multiplication.
A Multipliable18f
object is returned by Decimal18f.multiplyExact()
,
hence an exact typed multiplication can be written as:
Decimal18f value = ... //some value Decimal18f product = value.multiplyExact().by(Decimal0f.FIVE);
Constructor and Description |
---|
Multipliable18f(Decimal<Scale18f> value)
Constructor with Decimal value to be encapsulated.
|
Modifier and Type | Method and Description |
---|---|
Decimal18f |
by(Decimal0f factor)
Returns a
Decimal whose value is (this * factor) . |
Decimal18f |
by(MutableDecimal0f factor)
Returns a
Decimal whose value is (this * factor) . |
boolean |
equals(Object obj)
Compares this Multipliable18f to the specified object.
|
Decimal<Scale18f> |
getValue()
Returns the value underlying this Multipliable18f.
|
int |
hashCode()
Returns a hash code for this Multipliable18f which happens to be the
hash code of the underlying
Decimal18f value. |
String |
toString()
Returns a string representation of this
Multipliable18f which is
simply the string representation of the underlying Decimal value . |
public Multipliable18f(Decimal<Scale18f> value)
value
- the decimal value to be wrapped as a multipliable objectpublic Decimal<Scale18f> getValue()
public Decimal18f by(Decimal0f factor)
Decimal
whose value is (this * factor)
. The
result is exact and has scale 18 which is the sum of the scales
of the Decimal that this multipliable object represents and the scale of
the factor
argument. An ArithmeticException
is thrown if the
product is out of the possible range for a Decimal18f
.
Note that the result is always a new instance.
factor
- the factor to multiply with the Decimal that this multipliable representsArithmeticException
- if an overflow occurs and product is out of the possible
range for a Decimal18f
public Decimal18f by(MutableDecimal0f factor)
Decimal
whose value is (this * factor)
. The
result is exact and has scale 18 which is the sum of the scales
of the Decimal that this multipliable object represents and the scale of
the factor
argument. An ArithmeticException
is thrown if the
product is out of the possible range for a Decimal18f
.
Note that the result is always a new instance.
factor
- the factor to multiply with the Decimal that this multipliable representsArithmeticException
- if an overflow occurs and product is out of the possible
range for a Decimal18f
public int hashCode()
Decimal18f
value.hashCode
in class Object
Decimal.hashCode()
public boolean equals(Object obj)
true
if and only if the argument is a Multipliable18f
with an equal underlying
value
.equals
in class Object
obj
- the object to compare withtrue
if the argument is a Multipliable18f
and if its value
is equal to this multipliables's value; false
otherwisegetValue()
,
Decimal.equals(Object)
public String toString()
Multipliable18f
which is
simply the string representation of the underlying Decimal value
.toString
in class Object
String
Decimal representation of this Multipliable18f
's
value with all the fraction digits (including trailing zeros)getValue()
,
Decimal.toString()