Overview | Package | Class | Tree | Deprecated | Index | Help | |||
PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--nl.coffee.math.NumberCentral
RealNumber
objects.
Method Summary | |
static RealNumber | add(RealNumber a,
RealNumber b)
Computes the sum of the arguments. |
static RationalNumber | createFraction(long numerator,
long denominator)
Returns a fraction with the given numerator and denominator, both being a long . |
static RationalNumber | createFraction(IntegerNumber numerator,
IntegerNumber denominator)
Returns a fraction with the given numerator and denominator. |
static IntegerNumber | createInteger(byte[] bytes)
Returns an integer number from a byte array in two's complement notation. |
static IntegerNumber | createRandomInteger(int numBytes)
Returns an IntegerNumber with a random value. |
static NumberFactory | getDefaultFactory()
Retrieves the default NumberFactory . |
static RealNumber | multiply(RealNumber a,
RealNumber b)
Computes the product of the arguments. |
static RealNumber | pow(RealNumber base,
RealNumber exponent)
Computes the a power for the given base and exponent. |
static void | setDefaultFactory(NumberFactory newDefault)
Sets the default NumberFactory .
|
static RationalNumber | valueOf(double n)
Returns a rational number from the given double . |
static IntegerNumber | valueOf(long n)
Returns a rational number from the given long . |
static IntegerNumber | valueOf(java.math.BigInteger n)
Converts a java.math. |
static RationalNumber | valueOf(java.math.BigDecimal n)
Converts a java.math. |
Methods inherited from class java.lang.Object | |
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait |
Method Detail |
public static final NumberFactory getDefaultFactory()
NumberFactory
. This method will
never return null
.NumberFactory
that is set as the default.public static final void setDefaultFactory(NumberFactory newDefault)
NumberFactory
.
The default NumberFactory
will be set to the
fallback default if the argument is null
.
factory
- the new default factory, or null
if the
default factory should be set to the fallback default.public static RealNumber add(RealNumber a, RealNumber b) throws java.lang.IllegalArgumentException
a
- the first operand
b
- the second operandnull
.public static RealNumber multiply(RealNumber a, RealNumber b) throws java.lang.IllegalArgumentException
a
- the first operand
b
- the second operandnull
.public static RealNumber pow(RealNumber base, RealNumber exponent) throws java.lang.IllegalArgumentException, java.lang.ArithmeticException
base
- the base for the power.
exponent
- the exponent for the power.null
.public static RationalNumber createFraction(long numerator, long denominator) throws java.lang.ArithmeticException
long
.
numerator
- the numerator for the fraction.
denominator
- the denominator for the fraction.public static RationalNumber createFraction(IntegerNumber numerator, IntegerNumber denominator) throws java.lang.ArithmeticException, java.lang.IllegalArgumentException
numerator
- the numerator for the fraction.
denominator
- the denominator for the fraction.null
.public static IntegerNumber createInteger(byte[] bytes) throws java.lang.IllegalArgumentException
bytes
- the two's complement byte array.null
or the array has length 0.public static RationalNumber valueOf(double n) throws java.lang.IllegalArgumentException
double
.
n
- the original value.RealNumber
.public static IntegerNumber valueOf(long n)
long
.
n
- the original value.RealNumber
.public static IntegerNumber valueOf(java.math.BigInteger n) throws java.lang.IllegalArgumentException
java.math.BigInteger
to an
IntegerNumber
.
n
- the BigInteger
to convert.null
.public static RationalNumber valueOf(java.math.BigDecimal n) throws java.lang.IllegalArgumentException
java.math.BigDecimal
to an
IntegerNumber
.
n
- the BigDecimal
to convert.null
.public static IntegerNumber createRandomInteger(int numBytes)
IntegerNumber
with a random value.
the
- maximum number of bytes for the constructed number.Overview | Package | Class | Tree | Deprecated | Index | Help | |||
PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |