gnu.math
public class IntNum extends RatNum implements Externalizable
Field Summary | |
---|---|
int | ival All integers are stored in 2's-complement form.
|
int[] | words |
Constructor Summary | |
---|---|
IntNum() | |
IntNum(int value) Create a new (non-shared) IntNum, and initialize to an int. |
Method Summary | |
---|---|
static IntNum | abs(IntNum x) |
static IntNum | add(int x, int y) Add two ints, yielding an IntNum. |
static IntNum | add(IntNum x, int y) Add an IntNum and an int, yielding a new IntNum. |
static IntNum | add(IntNum x, IntNum y) Add two IntNums, yielding their sum as another IntNum. |
static IntNum | add(IntNum x, IntNum y, int k) Add two IntNums, yielding their sum as another IntNum. |
Numeric | add(Object y, int k) |
static IntNum | alloc(int nwords) Allocate a new non-shared IntNum. |
BigDecimal | asBigDecimal() |
BigInteger | asBigInteger() |
IntNum | canonicalize() |
static int | compare(IntNum x, IntNum y) Return -1, 0, or 1, depending on which value is greater. |
static int | compare(IntNum x, long y) Return -1, 0, or 1, depending on which value is greater. |
int | compare(Object obj) |
IntNum | denominator() |
Numeric | div(Object y) |
static void | divide(long x, long y, IntNum quotient, IntNum remainder, int rounding_mode) |
static void | divide(IntNum x, IntNum y, IntNum quotient, IntNum remainder, int rounding_mode) Divide two integers, yielding quotient and remainder. |
double | doubleValue() |
static boolean | equals(IntNum x, IntNum y) |
boolean | equals(Object obj) |
void | format(int radix, StringBuffer buffer) |
static int | gcd(int a, int b) Calculate Greatest Common Divisor for non-negative ints. |
static IntNum | gcd(IntNum x, IntNum y) |
void | getAbsolute(int[] words) Copy the abolute value of this into an array of words.
|
int | hashCode() |
int | intLength() Calculates {@code ceiling(log2(this < 0 ? -this : this+1))}.
|
int | intValue() |
static int | intValue(Object obj) Cast an Object to an int. |
boolean | isMinusOne() |
boolean | isNegative() |
boolean | isOdd() |
boolean | isOne() |
boolean | isZero() |
static IntNum | lcm(IntNum x, IntNum y) |
long | longValue() |
static IntNum | make(int value) Return a (possibly-shared) IntNum with a given int value. |
static IntNum | make(long value) Return a (possibly-shared) IntNum with a given long value. |
static IntNum | make(int[] words, int len) Make a canonicalized IntNum from an array of words.
|
static IntNum | make(int[] words) |
static IntNum | makeU(long value) Make an IntNum from an unsigned 64-bit value. |
static IntNum | minusOne() Return the IntNum for -1. |
static IntNum | modulo(IntNum x, IntNum y) |
Numeric | mul(Object y) |
static IntNum | neg(IntNum x) |
Numeric | neg() |
static boolean | negate(int[] dest, int[] src, int len) Set dest[0:len-1] to the negation of src[0:len-1].
|
IntNum | numerator() |
static IntNum | one() |
Numeric | power(IntNum y) |
static IntNum | power(IntNum x, int y) Calculate the integral power of an IntNum. |
static IntNum | quotient(IntNum x, IntNum y, int rounding_mode) |
static IntNum | quotient(IntNum x, IntNum y) |
void | readExternal(ObjectInput in) |
Object | readResolve() |
void | realloc(int nwords) Change words.length to nwords.
|
static IntNum | remainder(IntNum x, IntNum y) |
double | roundToDouble(int exp, boolean neg, boolean remainder) Convert a semi-processed IntNum to double.
|
void | set(int y) Destructively set the value of this to an int. |
void | set(long y) Destructively set the value of this to a long. |
void | set(int[] words, int length) Destructively set the value of this to the given words.
|
void | set(IntNum y) Destructively set the value of this to that of y. |
void | setAdd(IntNum x, int y) Set this to the sum of x and y.
|
void | setAdd(int y) Destructively add an int to this. |
void | setNegative(IntNum x) Destructively set this to the negative of x.
|
void | setNegative() Destructively negate this. |
static IntNum | shift(IntNum x, int count) |
int | sign() |
static IntNum | sub(IntNum x, IntNum y) Subtract two IntNums, yielding their sum as another IntNum. |
static IntNum | ten() |
static IntNum | times(int x, int y) Multiply two ints, yielding an IntNum. |
static IntNum | times(IntNum x, int y) |
static IntNum | times(IntNum x, IntNum y) |
IntNum | toExactInt(int rounding_mode) |
RealNum | toInt(int rounding_mode) |
String | toString(int radix) |
static IntNum | valueOf(char[] buf, int offset, int length, int radix, boolean negative) |
static IntNum | valueOf(String s, int radix) |
static IntNum | valueOf(byte[] digits, int byte_len, boolean negative, int radix) |
static IntNum | valueOf(String s) |
static int | wordsNeeded(int[] words, int len) Calculate how many words are significant in words[0:len-1].
|
void | writeExternal(ObjectOutput out) |
static IntNum | zero() |
Parameters: value the initial value
Parameters: nwords number of words to allocate
Parameters: x the numerator in the division y the denominator in the division quotient is set to the quotient of the result (iff quotient!=null) remainder is set to the remainder of the result (iff remainder!=null) rounding_mode one of FLOOR, CEILING, TRUNCATE, or ROUND.
Parameters: x the value (base) to exponentiate y the exponent (must be non-negative)
Parameters: exp power of two, positive or negative, by which to multiply neg true if negative remainder true if the IntNum is the result of a truncating division that had non-zero remainder. To ensure proper rounding in this case, the IntNum must have at least 54 bits.
Serial Data: If the value is in the range (int)0xC000000 .. 0x7fffffff (inclusive) write out the value (using writeInt). Otherwise, write (using writeInt) (0x80000000|nwords), where nwords is the number of words following. The words are the minimal 2's complement big-endian representation of the value, written using writeint. (Even if the current value is not canonicalized, the output is).