JML

org.jmlspecs.models
Class JMLFiniteInteger

java.lang.Object
  extended byorg.jmlspecs.models.JMLInfiniteIntegerClass
      extended byorg.jmlspecs.models.JMLFiniteInteger
All Implemented Interfaces:
Cloneable, Comparable, JMLComparable, JMLInfiniteInteger, JMLType, Serializable

public class JMLFiniteInteger
extends JMLInfiniteIntegerClass

Arbitrary precision integers with a finite value.

Version:
$Revision: 1.22 $
Author:
Gary T. Leavens
See Also:
BigInteger

Field Summary
static JMLFiniteInteger ONE
          The number one (1).
protected  BigInteger val
           
static JMLFiniteInteger ZERO
          The number zero (0).
 
Constructor Summary
JMLFiniteInteger()
          Initialize this finite integer to zero (0).
JMLFiniteInteger(BigInteger n)
          Initialize this finite integer from the given BigInteger.
JMLFiniteInteger(long n)
          Initialize this finite integer from the given long.
 
Method Summary
 JMLInfiniteInteger add(JMLInfiniteInteger n)
          Return the sum of this integer and the argument.
 int compareTo(Object o)
          Compare this to o, returning a comparison code.
 int compareTo(JMLInfiniteInteger n)
          Compare this to the given integer, returning a comparison code.
 JMLInfiniteInteger divide(JMLInfiniteInteger n)
          Return the quotient of this integer divided by the argument.
 double doubleValue()
          Return this integer approximated by a double.
 BigInteger finiteValue()
          Return the value of this integer.
 float floatValue()
          Return this integer approximated by a float.
 int hashCode()
          Return a hash code for this object.
 int intValue()
          Converts this BigInteger to an integer
 boolean isFinite()
          Return true.
 long longValue()
          Converts this BigInteger to a long
 JMLInfiniteInteger mod(JMLInfiniteInteger n)
          Return this integer modulo the argument.
 JMLInfiniteInteger multiply(JMLInfiniteInteger n)
          Return the product of this integer and the argument.
 JMLInfiniteInteger negate()
          Return the negation of this integer.
 JMLInfiniteInteger pow(int n)
          Return this integer raised to the argument's power.
 JMLInfiniteInteger remainder(JMLInfiniteInteger n)
          Return the remainder of this integer divided by the argument.
 int signum()
          Return the sign of this integer.
 JMLInfiniteInteger subtract(JMLInfiniteInteger n)
          Return the difference between this integer and the argument.
 String toString()
          Return the decimal representation of this integer.
 String toString(int radix)
          Return the digits representing this integer in the given radix.
 
Methods inherited from class org.jmlspecs.models.JMLInfiniteIntegerClass
abs, clone, equals, greaterThan, greaterThanOrEqualTo, lessThan, lessThanOrEqualTo, max, min
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

val

protected final BigInteger val

ZERO

public static final JMLFiniteInteger ZERO
The number zero (0).


ONE

public static final JMLFiniteInteger ONE
The number one (1).

Constructor Detail

JMLFiniteInteger

public JMLFiniteInteger()
Initialize this finite integer to zero (0).


JMLFiniteInteger

public JMLFiniteInteger(BigInteger n)
                 throws IllegalArgumentException
Initialize this finite integer from the given BigInteger.

Throws:
IllegalArgumentException

JMLFiniteInteger

public JMLFiniteInteger(long n)
Initialize this finite integer from the given long.

Method Detail

signum

public int signum()
Return the sign of this integer.


isFinite

public boolean isFinite()
Return true.


finiteValue

public BigInteger finiteValue()
Return the value of this integer.


compareTo

public int compareTo(JMLInfiniteInteger n)
Compare this to the given integer, returning a comparison code.


compareTo

public int compareTo(Object o)
              throws NullPointerException,
                     ClassCastException
Compare this to o, returning a comparison code.

Parameters:
o - the object this is compared to.
Throws:
ClassCastException - when o is not a JMLInfiniteInteger or a BigInteger.
NullPointerException
See Also:
JMLInfiniteInteger.equals(Object), JMLInfiniteInteger.greaterThanOrEqualTo(org.jmlspecs.models.JMLInfiniteInteger), JMLInfiniteInteger.greaterThan(org.jmlspecs.models.JMLInfiniteInteger), JMLInfiniteInteger.lessThanOrEqualTo(org.jmlspecs.models.JMLInfiniteInteger), JMLInfiniteInteger.lessThan(org.jmlspecs.models.JMLInfiniteInteger)

hashCode

public int hashCode()
Return a hash code for this object.

Specified by:
hashCode in interface JMLInfiniteInteger
Overrides:
hashCode in class Object

negate

public JMLInfiniteInteger negate()
Return the negation of this integer.

See Also:
JMLInfiniteInteger.abs(), JMLInfiniteInteger.subtract(org.jmlspecs.models.JMLInfiniteInteger)

add

public JMLInfiniteInteger add(JMLInfiniteInteger n)
Return the sum of this integer and the argument.

See Also:
JMLInfiniteInteger.subtract(org.jmlspecs.models.JMLInfiniteInteger)

subtract

public JMLInfiniteInteger subtract(JMLInfiniteInteger n)
Return the difference between this integer and the argument.

See Also:
JMLInfiniteInteger.add(org.jmlspecs.models.JMLInfiniteInteger), JMLInfiniteInteger.negate()

multiply

public JMLInfiniteInteger multiply(JMLInfiniteInteger n)
Return the product of this integer and the argument.

See Also:
JMLInfiniteInteger.divide(org.jmlspecs.models.JMLInfiniteInteger), JMLInfiniteInteger.remainder(org.jmlspecs.models.JMLInfiniteInteger), JMLInfiniteInteger.mod(org.jmlspecs.models.JMLInfiniteInteger)

divide

public JMLInfiniteInteger divide(JMLInfiniteInteger n)
Return the quotient of this integer divided by the argument.

See Also:
JMLInfiniteInteger.multiply(org.jmlspecs.models.JMLInfiniteInteger), JMLInfiniteInteger.remainder(org.jmlspecs.models.JMLInfiniteInteger), JMLInfiniteInteger.mod(org.jmlspecs.models.JMLInfiniteInteger)

remainder

public JMLInfiniteInteger remainder(JMLInfiniteInteger n)
Return the remainder of this integer divided by the argument.

See Also:
JMLInfiniteInteger.divide(org.jmlspecs.models.JMLInfiniteInteger), JMLInfiniteInteger.mod(org.jmlspecs.models.JMLInfiniteInteger)

mod

public JMLInfiniteInteger mod(JMLInfiniteInteger n)
                       throws ArithmeticException
Return this integer modulo the argument.

Throws:
ArithmeticException
See Also:
JMLInfiniteInteger.divide(org.jmlspecs.models.JMLInfiniteInteger), JMLInfiniteInteger.remainder(org.jmlspecs.models.JMLInfiniteInteger)

pow

public JMLInfiniteInteger pow(int n)
Return this integer raised to the argument's power.


doubleValue

public double doubleValue()
Return this integer approximated by a double.

See Also:
JMLInfiniteInteger.floatValue()

floatValue

public float floatValue()
Return this integer approximated by a float.

See Also:
JMLInfiniteInteger.doubleValue()

toString

public String toString()
Return the decimal representation of this integer.

Specified by:
toString in interface JMLInfiniteInteger
Overrides:
toString in class Object
See Also:
JMLInfiniteInteger.toString(int)

toString

public String toString(int radix)
Return the digits representing this integer in the given radix.

See Also:
JMLInfiniteInteger.toString()

longValue

public long longValue()
Converts this BigInteger to a long


intValue

public int intValue()
Converts this BigInteger to an integer


JML

JML is Copyright (C) 1998-2002 by Iowa State University and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This release depends on code from the MultiJava project and is based in part on the Kopi project Copyright (C) 1990-99 DMS Decision Management Systems Ges.m.b.H.