public final class NumberCentral
extends java.lang.Object
RealNumber
objects.Modifier and Type | Method and Description |
---|---|
static void |
checkDivideByZero(RealNumber n)
Checks if dividing by the specified number would result in a division by
zero.
|
static RationalNumber |
createFraction(IntegerNumber numerator,
IntegerNumber denominator)
Returns a fraction with the given numerator and denominator.
|
static RationalNumber |
createFraction(int numerator,
int denominator)
Returns a fraction with the given numerator and denominator, both
being an
int . |
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 java.lang.String |
getVersion()
Returns the current version of JUMP.
|
static RationalNumber |
valueOf(java.math.BigDecimal n)
Converts a
BigDecimal to a RationalNumber . |
static IntegerNumber |
valueOf(java.math.BigInteger n)
Converts a
BigInteger to an IntegerNumber . |
static IntegerNumber |
valueOf(byte n)
Converts a
byte to an IntegerNumber . |
static RationalNumber |
valueOf(double n)
Converts a
double to a RationalNumber . |
static RationalNumber |
valueOf(float n)
Converts a
float to a RationalNumber . |
static IntegerNumber |
valueOf(int n)
Converts an
int to an IntegerNumber . |
static IntegerNumber |
valueOf(long n)
Converts a
long to an IntegerNumber . |
static IntegerNumber |
valueOf(short n)
Converts a
short to an IntegerNumber . |
public static java.lang.String getVersion()
"0.5"
,
never null
.public static RationalNumber createFraction(int numerator, int denominator) throws java.lang.ArithmeticException
int
.numerator
- the numerator for the fraction.denominator
- the denominator for the fraction, not 0.null
.java.lang.ArithmeticException
- if denominator == 0.
public static RationalNumber createFraction(IntegerNumber numerator, IntegerNumber denominator) throws java.lang.ArithmeticException, java.lang.IllegalArgumentException
numerator
- the numerator for the fraction, not null
.denominator
- the denominator for the fraction, not null
.null
.java.lang.IllegalArgumentException
- if numerator == null || denominator == null
.java.lang.ArithmeticException
- if the denominator is zero, i.e.
denominator.equals(SmallIntegerNumber.ZERO
)
.public static IntegerNumber createInteger(byte[] bytes) throws java.lang.IllegalArgumentException
bytes
- the two's complement byte array, not null
.null
.java.lang.IllegalArgumentException
- if bytes == null
.public static RationalNumber valueOf(double n) throws java.lang.IllegalArgumentException
double
to a RationalNumber
.n
- the value to be converted, not an infinite number, nor NaN.null
.java.lang.IllegalArgumentException
- if Double.isInfinite(n) || Double.isNaN(n)
public static RationalNumber valueOf(float n) throws java.lang.IllegalArgumentException
float
to a RationalNumber
.n
- the value to be converted.null
.java.lang.IllegalArgumentException
- if Float.isInfinite(n) || Float.isNaN(n)
public static IntegerNumber valueOf(long n)
long
to an IntegerNumber
.n
- the value to be converted.null
.public static IntegerNumber valueOf(int n)
int
to an IntegerNumber
.n
- the value to be converted.null
.public static IntegerNumber valueOf(short n)
short
to an IntegerNumber
.n
- the value to be converted.null
.public static IntegerNumber valueOf(byte n)
byte
to an IntegerNumber
.n
- the value to be converted.null
.public static IntegerNumber valueOf(java.math.BigInteger n) throws java.lang.IllegalArgumentException
BigInteger
to an IntegerNumber
.n
- the value to be converted, not null
.null
.java.lang.IllegalArgumentException
- if n == null
.public static RationalNumber valueOf(java.math.BigDecimal n) throws java.lang.IllegalArgumentException
BigDecimal
to a RationalNumber
.n
- the value to be converted, not null
.null
.java.lang.IllegalArgumentException
- if n == null
.public static IntegerNumber createRandomInteger(int numBytes) throws java.lang.IllegalArgumentException
IntegerNumber
with a random value. The maximum
number of bytes for the integer number must be specified.numBytes
- the maximum number of bytes for the constructed number, at least 1.null
.java.lang.IllegalArgumentException
- if numBytes < 1
.public static void checkDivideByZero(RealNumber n) throws java.lang.IllegalArgumentException, java.lang.ArithmeticException
ArithmeticException
is thrown.n
- the number to compare with zero, not null
.java.lang.IllegalArgumentException
- if n == null
.java.lang.ArithmeticException
- if n.getSign
() == 0
.