package java.math;
-import java.math.BigInteger;
-
public class BigDecimal extends Number implements Comparable
{
private BigInteger intVal;
private int scale;
private static final long serialVersionUID = 6108874887143696463L;
- private final static BigDecimal ZERO =
+ private static final BigDecimal ZERO =
new BigDecimal (BigInteger.valueOf (0), 0);
- private final static BigDecimal ONE =
+ private static final BigDecimal ONE =
new BigDecimal (BigInteger.valueOf (1), 0);
- public final static int ROUND_UP = 0;
- public final static int ROUND_DOWN = 1;
- public final static int ROUND_CEILING = 2;
- public final static int ROUND_FLOOR = 3;
- public final static int ROUND_HALF_UP = 4;
- public final static int ROUND_HALF_DOWN = 5;
- public final static int ROUND_HALF_EVEN = 6;
- public final static int ROUND_UNNECESSARY = 7;
+ public static final int ROUND_UP = 0;
+ public static final int ROUND_DOWN = 1;
+ public static final int ROUND_CEILING = 2;
+ public static final int ROUND_FLOOR = 3;
+ public static final int ROUND_HALF_UP = 4;
+ public static final int ROUND_HALF_DOWN = 5;
+ public static final int ROUND_HALF_EVEN = 6;
+ public static final int ROUND_UNNECESSARY = 7;
public BigDecimal (BigInteger num)
{
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package java.math;
import gnu.java.math.MPN;
-import java.util.Random;
+
+import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import java.io.IOException;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date December 20, 1999.
- */
+import java.util.Random;
/**
* Written using on-line Java Platform 1.2 API Specification, as well
* Based primarily on IntNum.java BitOps.java by Per Bothner <per@bothner.com>
* (found in Kawa 1.6.62).
*
- * Status: Believed complete and correct.
+ * @author Warren Levy <warrenl@cygnus.com>
+ * @date December 20, 1999.
+ * @status believed complete and correct.
*/
-
public class BigInteger extends Number implements Comparable
{
/** All integers are stored in 2's-complement form.
* If words == null, the ival is the value of this BigInteger.
* Otherwise, the first ival elements of words make the value
* of this BigInteger, stored in little-endian order, 2's-complement form. */
- transient private int ival;
- transient private int[] words;
+ private transient int ival;
+ private transient int[] words;
// Serialization fields.
private int bitCount = -1;
}
}
- private final boolean isNegative()
+ private boolean isNegative()
{
return (words == null ? ival : words[ival - 1]) < 0;
}
return compareTo(this, val) > 0 ? this : val;
}
- private final boolean isZero()
+ private boolean isZero()
{
return words == null && ival == 0;
}
- private final boolean isOne()
+ private boolean isOne()
{
return words == null && ival == 1;
}
}
/** Add two ints, yielding a BigInteger. */
- private static final BigInteger add(int x, int y)
+ private static BigInteger add(int x, int y)
{
return valueOf((long) x + (long) y);
}
}
/** Destructively add an int to this. */
- private final void setAdd(int y)
+ private void setAdd(int y)
{
setAdd(this, y);
}
/** Destructively set the value of this to a long. */
- private final void set(long y)
+ private void set(long y)
{
int i = (int) y;
if ((long) i == y)
/** Destructively set the value of this to the given words.
* The words array is reused, not copied. */
- private final void set(int[] words, int length)
+ private void set(int[] words, int length)
{
this.ival = length;
this.words = words;
}
/** Destructively set the value of this to that of y. */
- private final void set(BigInteger y)
+ private void set(BigInteger y)
{
if (y.words == null)
set(y.ival);
return add(this, val, -1);
}
- private static final BigInteger times(BigInteger x, int y)
+ private static BigInteger times(BigInteger x, int y)
{
if (y == 0)
return ZERO;
return result.canonicalize();
}
- private static final BigInteger times(BigInteger x, BigInteger y)
+ private static BigInteger times(BigInteger x, BigInteger y)
{
if (y.words == null)
return times(x, y.ival);
return BigInteger.make(rwords, rlen);
}
- private static final int[] euclidInv(int a, int b, int prevDiv)
+ private static int[] euclidInv(int a, int b, int prevDiv)
{
if (b == 0)
throw new ArithmeticException("not invertible");
return xy;
}
- private static final void euclidInv(BigInteger a, BigInteger b,
- BigInteger prevDiv, BigInteger[] xy)
+ private static void euclidInv(BigInteger a, BigInteger b,
+ BigInteger prevDiv, BigInteger[] xy)
{
if (b.isZero())
throw new ArithmeticException("not invertible");
}
/** Calculate Greatest Common Divisor for non-negative ints. */
- private static final int gcd(int a, int b)
+ private static int gcd(int a, int b)
{
// Euclid's algorithm, copied from libg++.
int tmp;
}
/** Destructively negate this. */
- private final void setNegative()
+ private void setNegative()
{
setNegative(this);
}