|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectch.javasoft.math.AbstractNumberOps<BigDecimal>
ch.javasoft.math.BigDecimalOperations
public class BigDecimalOperations
Number operations for BigDecimal numbers.
The instantiation of a BigDecimalOperations requires a
MathContext which defines rounding.
| Constructor Summary | |
|---|---|
BigDecimalOperations(int setPrecision)
Constructs a new BigDecimalOperations with the specified
precision and the HALF_UP rounding
mode. |
|
BigDecimalOperations(MathContext mathContext)
Constructor for BigDecimalOperations with specified math
context defining rounding |
|
BigDecimalOperations(String contextVal)
Constructs a new BigDecimalOperations with MathContext
from a string. |
|
| Method Summary | |
|---|---|
BigDecimal |
abs(BigDecimal number)
Returns the absolute value of the given number, i.e. |
BigDecimal |
add(BigDecimal numA,
BigDecimal numB)
Returns the sum of the two values, i.e. |
int |
byteLength()
Returns the byte array length if NumberOperations.toByteArray(Number) is used and if
this size is fixed, and -1 if the size may vary depending on the number
instance |
int |
compare(BigDecimal o1,
BigDecimal o2)
|
BigDecimal |
divide(BigDecimal numA,
BigDecimal numB)
Returns the ratio of the two values, i.e. |
BigDecimal |
fromByteArray(byte[] bytes)
Converts the byte array containing binary data into a new number instance. |
MathContext |
getMathContext()
Returns the math context defined when instantiating this BigDecimalOperations |
BigDecimal |
invert(BigDecimal number)
Returns the inverted value, i.e. |
boolean |
isOne(BigDecimal number)
Returns true if this value is numerically equal to one, i.e. |
BigDecimal |
multiply(BigDecimal numA,
BigDecimal numB)
Returns the product of the two values, i.e. |
BigDecimal |
negate(BigDecimal number)
Returns the negated value, i.e. |
BigDecimal[] |
newArray(int size)
Create a new array of the underlying number type |
BigDecimal[][] |
newArray(int rows,
int cols)
Create a new 2 dimensional array of the underlying number type |
Class<BigDecimal> |
numberClass()
The class representing numbers of this number operations instance |
BigDecimal |
one()
Returns the value representing one |
BigDecimal |
pow(BigDecimal numA,
BigDecimal numB)
Returns the powered value, i.e. |
BigDecimal |
readFrom(DataInput in)
Reads binary data from the given data input. |
BigDecimal |
reduce(BigDecimal number)
Returns the rounded number according to the current math context, that is,
BigDecimal.round(MathContext) is called |
BigDecimal[] |
reduceVector(boolean cloneOnChange,
BigDecimal... vector)
Returns the unchanged vector |
int |
signum(BigDecimal number)
Returns signum of the value, i.e. |
BigDecimal |
subtract(BigDecimal numA,
BigDecimal numB)
Returns the difference of the two values, i.e. |
byte[] |
toByteArray(BigDecimal number)
Converts this number to binary data and returns it as a byte array. |
BigDecimal |
valueOf(double value)
Create an instance of the underlying number type based on the submitted double value |
BigDecimal |
valueOf(long value)
Create an instance of the underlying number type based on the submitted long integer value |
BigDecimal |
valueOf(Number number)
Create an instance of the underlying number type based on the submitted number |
BigDecimal |
valueOf(String s)
Create an instance of the underlying number type based on the given string representation of the number |
void |
writeTo(BigDecimal number,
DataOutput out)
Converts this number to binary data and writes it to the data output. |
BigDecimal |
zero()
Returns the value representing zero |
| Methods inherited from class ch.javasoft.math.AbstractNumberOps |
|---|
isNegative, isNonNegative, isNonPositive, isNonZero, isPositive, isZero, max, max, min, min |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.Comparator |
|---|
equals |
| Constructor Detail |
|---|
public BigDecimalOperations(MathContext mathContext)
BigDecimalOperations with specified math
context defining rounding
public BigDecimalOperations(int setPrecision)
BigDecimalOperations with the specified
precision and the HALF_UP rounding
mode.
setPrecision - The non-negative int precision setting.
IllegalArgumentException - if the setPrecision parameter is
less than zero.public BigDecimalOperations(String contextVal)
BigDecimalOperations with MathContext
from a string.
The string must be in the same format as that produced by the
MathContext.toString() method.
An IllegalArgumentException is thrown if the precision
section of the string is out of range (< 0) or the string is
not in the format created by the Object.toString() method.
contextVal - The string to be parsed
IllegalArgumentException - if the precision section is out of range
or of incorrect format
NullPointerException - if the argument is null| Method Detail |
|---|
public MathContext getMathContext()
BigDecimalOperations
public Class<BigDecimal> numberClass()
NumberOperations
public BigDecimal[] newArray(int size)
NumberOperations
public BigDecimal[][] newArray(int rows,
int cols)
NumberOperations
public BigDecimal valueOf(String s)
NumberOperations
public BigDecimal valueOf(Number number)
NumberOperations
public BigDecimal valueOf(long value)
NumberOperations
public BigDecimal valueOf(double value)
NumberOperations
public BigDecimal abs(BigDecimal number)
NumberOperations
abs in interface NumberOperations<BigDecimal>abs in class AbstractNumberOps<BigDecimal>
public BigDecimal add(BigDecimal numA,
BigDecimal numB)
NumberOperations
public BigDecimal divide(BigDecimal numA,
BigDecimal numB)
NumberOperationsFor integer types, an integer division is performed, ignoring possible remainders
public BigDecimal invert(BigDecimal number)
NumberOperations
invert in interface NumberOperations<BigDecimal>invert in class AbstractNumberOps<BigDecimal>public boolean isOne(BigDecimal number)
NumberOperations
isOne in interface NumberOperations<BigDecimal>isOne in class AbstractNumberOps<BigDecimal>
public BigDecimal multiply(BigDecimal numA,
BigDecimal numB)
NumberOperations
public BigDecimal negate(BigDecimal number)
NumberOperations
public BigDecimal one()
NumberOperations
public BigDecimal subtract(BigDecimal numA,
BigDecimal numB)
NumberOperations
public BigDecimal zero()
NumberOperations
public int compare(BigDecimal o1,
BigDecimal o2)
public BigDecimal reduce(BigDecimal number)
math context, that is,
BigDecimal.round(MathContext) is called
public BigDecimal[] reduceVector(boolean cloneOnChange,
BigDecimal... vector)
cloneOnChange - if a reduction can be made, the array is cloned
and the original array is not changed. If no
reduction can be made, or if cloneOnChange
is false, the original array will be returned,
unmodified in the former case, and with reduced
values in the latter case.vector - the vector to reducepublic int signum(BigDecimal number)
NumberOperations
public BigDecimal pow(BigDecimal numA,
BigDecimal numB)
NumberOperations
public byte[] toByteArray(BigDecimal number)
NumberOperationsNumberOperations.fromByteArray(byte[]) method.
public void writeTo(BigDecimal number,
DataOutput out)
throws IOException
NumberOperationsNumberOperations.readFrom(DataInput).
IOExceptionpublic BigDecimal fromByteArray(byte[] bytes)
NumberOperations.toByteArray(Number) method.
Returns the value as stored, without applying rounding according to the
math context.
public BigDecimal readFrom(DataInput in)
throws IOException
NumberOperations.writeTo(Number, DataOutput)
Returns the value as stored, without applying rounding according to the
math context.
IOExceptionpublic int byteLength()
NumberOperationsNumberOperations.toByteArray(Number) is used and if
this size is fixed, and -1 if the size may vary depending on the number
instance
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||