gt: 		else if (valueClass == LONG)
context: /* Mesquite source code.  Copyright 1997 and onward, W. Maddison and D. Maddison. 
  
  
  Disclaimer:  The Mesquite source code is lengthy and we are few.  There are no doubt inefficiencies and goofs in this code. 
  The commenting leaves much to be desired. Please approach this source code with the spirit of helping out.
  Perhaps with your help we can be more than a few, and make Mesquite better.
  
  Mesquite is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY.
  Mesquite's web site is http://mesquiteproject.org
  
  This source code and its compiled class files are free and modifiable under the terms of 
  GNU Lesser General Public License.  (http://www.gnu.org/copyleft/lesser.html)
   */
  package mesquite.lib;
  
  import java.awt.*;
  
  /*Last documented:  August 1999 */
  /* ======================================================================== */
  /**This class is used to store numbers flexibly, so that system doesn't need to know whether int, long or double.
  Automatically upgrades calculations to use long or double as needed.  Because they have the overhead of objects,
  it is best to avoid their wanton proliferation.  If an array is needed, better to use the NumberArray,
  which behaves similarly but stores the data as a primitive type arrays.  
  Most of the methods in MesquiteNumber use the incoming parameter 
  	as a guide to how the data should be stored.  Thus there are int, long, and
  	double versions of many methods.  Calculations involving mixed types automatically
  	upgrade the storage to the bigger type. */
  public class MesquiteNumber implements Listable, WithStringDetails{
  	private int intValue=0;
  	private long longValue=0;
  	private double doubleValue=0;
  	private int valueClass = 0;
  	public static final int INT = 0;
  	public static final int LONG = 1;
  	public static final int DOUBLE = 2;
  	private boolean unassignedFlag = true; // have inappplicable?
  	private boolean infiniteFlag = false;
  	private MesquiteNumber temp = null;
  	private MesquiteNumber temp2 = null;
  	private MesquiteNumber[] auxiliaries = null;
  	private String name = null;
  	public static long totalCreated = 0;
  	boolean watchpoint = false;
  	public MesquiteNumber() {
  		setToUnassigned();
  		totalCreated++;
  	}
  	public MesquiteNumber(int value) {
  		this.intValue=value;
  		unassignedFlag = value==MesquiteInteger.unassigned;
  		valueClass =INT;
  		totalCreated++;
  	}
  
  	public MesquiteNumber(long value) {
  		this.longValue=value;
  		unassignedFlag = value==MesquiteLong.unassigned;
  		valueClass = LONG;
  		totalCreated++;
  	}
  	public MesquiteNumber(double value) {
  		this.doubleValue=value;
  		unassignedFlag = value==MesquiteDouble.unassigned;
  		valueClass = DOUBLE;
  		totalCreated++;
  	}
  	public MesquiteNumber(MesquiteNumber toCopy) {
  		this(toCopy, false);
  	}
  	public MesquiteNumber(MesquiteNumber toCopy, boolean copyAuxiliaries) {
  		setValue(toCopy);
  		setName(toCopy.getName());
  		copyAuxiliaries(toCopy.getAuxiliaries());
  		totalCreated++;
  	}
  	public void setWatchpoint(boolean w){
  		watchpoint = w;
  	}
  	public int getValueClass(){
  		return valueClass;
  	}
  	public void copyFrom(MesquiteNumber n){
  		intValue = n.intValue;
  		longValue = n.longValue;
  		doubleValue = n.doubleValue;
  		valueClass = n.valueClass;
  		unassignedFlag = n.unassignedFlag;
  		infiniteFlag = n.infiniteFlag;
  		name = n.name;
  		watchpoint = n.watchpoint;
  	}
  	public void copyFrom(MesquiteParameter n){
  		intValue = 0;
  		longValue = 0;
  		doubleValue = n.getValue();
  		unassignedFlag = doubleValue==MesquiteDouble.unassigned;
  		valueClass = DOUBLE;
  		name = n.getName();
  	}
  	public MesquiteNumber[] getAuxiliaries(){  // in case a complex result with multiple numbers is needed
  		return auxiliaries;
  	}
  	public void copyAuxiliaries(MesquiteNumber[] aux){  // in case a complex result with multiple numbers is needed
  		if (aux == null){
  			auxiliaries = null;
  			return;
  		}
  		if (auxiliaries == null || auxiliaries.length != aux.length)
  			auxiliaries = new MesquiteNumber[aux.length];
  		for (int i = 0; i< auxiliaries.length; i++) {
  			if (auxiliaries[i] == null){
  				auxiliaries[i] = new MesquiteNumber(aux[i]);
  			}
  			else
  				auxiliaries[i].copyFrom(aux[i]);
  		}
  	}
  	public void copyAuxiliaries(MesquiteParameter[] aux){  // in case a complex result with multiple numbers is needed
  		if (aux == null){
  			auxiliaries = null;
  			return;
  		}
  		if (auxiliaries == null || auxiliaries.length != aux.length)
  			auxiliaries = new MesquiteNumber[aux.length];
  		for (int i = 0; i< auxiliaries.length; i++) {
  			if (auxiliaries[i] == null)
  				auxiliaries[i] = new MesquiteNumber();
  			auxiliaries[i].copyFrom(aux[i]);
  			if (aux[i].getConstrainedTo() != null && auxiliaries[i].getName()!= null)
  				auxiliaries[i].setName(auxiliaries[i].getName() + " (= " + aux[i].getConstrainedTo().getName() + ")");
  		}
  	}
  	public void setName(String n){
  		name = n;
  	}
  	public String getName(){
  		return name;
  	}
  	/*--------------------------------GET/SET--------------------------*/
  	/** Returns the stored value as an int */
  	public int getIntValue() {
  		if (isInfinite())
  			return MesquiteInteger.infinite;
  		if (isUnassigned())
  			return MesquiteInteger.unassigned;
  
  		if (valueClass==INT)
  			return intValue;
  		else if (valueClass == LONG)
  			return (int)(longValue);
  		else if (valueClass == DOUBLE)
  			return (int)doubleValue;
  //		return java.lang.Math.round(doubleValue);
  		else return 0;
  	}
  	/*...........................................................*/
  	/** Returns the stored value as a long */
  	public long getLongValue() {
  		if (isInfinite())
  			return MesquiteLong.infinite;
  		if (isUnassigned())
  			return MesquiteLong.unassigned;
  		if (valueClass==INT)
  			return intValue;
  		else if (valueClass == LONG)
  			return longValue;
  		else if (valueClass == DOUBLE)
  			return (long)doubleValue;
  		else return 0;
  	}
  	/*...........................................................*/
  	/** Returns the stored value as a double */
  	public double getDoubleValue() {
  		if (isInfinite())
  			return MesquiteDouble.infinite;
  		if (isUnassigned())
  			return MesquiteDouble.unassigned;
  		if (valueClass==INT)
  			return intValue;
  		else if (valueClass == LONG)
  			return (longValue);
  		else if (valueClass == DOUBLE)
  			return doubleValue;
  		else return 0;
  	}
  	/** Sets the stored value to the passed integer */
  	public void setValue(int v) {
  		if (watchpoint) MesquiteMessage.printStackTrace("MesquiteNumber changed value to " + v);
  		intValue = v;
  		valueClass = INT;
  		unassignedFlag = (v==MesquiteInteger.unassigned);
  		infiniteFlag = (v==MesquiteInteger.infinite);
  	}
  
  	/** Sets the stored value to the passed long */
  	public void setValue(long v) {
  		if (watchpoint) MesquiteMessage.printStackTrace("MesquiteNumber changed value to " + v);
  		longValue = v;
  		valueClass =LONG;
  
  		unassignedFlag = (v==MesquiteLong.unassigned);
  		infiniteFlag = (v==MesquiteLong.infinite);
  	}
  
  	/** Sets the stored value to the passed double */
  	public void setValue(double v) {
  		if (watchpoint) MesquiteMessage.printStackTrace("MesquiteNumber changed value to " + v);
  		doubleValue = v;
  		valueClass=DOUBLE;
  		unassignedFlag = (v==MesquiteDouble.unassigned);
  		infiniteFlag = (v==MesquiteDouble.infinite);
  	}
  
  	/** Sets the values to be the same as the passed MesquiteNumber */
  	public void setValue(MesquiteNumber v) {
  		if (v==null)
  			return;
  		if (watchpoint) MesquiteMessage.printStackTrace("MesquiteNumber changed value to " + v);
  		valueClass=v.valueClass;
  		intValue=v.intValue;
  		longValue=v.longValue;
  		doubleValue=v.doubleValue;
  		unassignedFlag = v.unassignedFlag;
  		infiniteFlag = v.infiniteFlag;
  	}
  	/*...........................................................*/
  	/** Sets the value to be that represented by the string*/
  	public void setValue(String toBeParsed) {
  		if (watchpoint) MesquiteMessage.printStackTrace("MesquiteNumber changed value to " + toBeParsed);
  		if (toBeParsed==null || toBeParsed.equalsIgnoreCase("unassigned") || toBeParsed.equalsIgnoreCase("?") || toBeParsed.equalsIgnoreCase("estimate")) //"?" included Apr 02
  			setToUnassigned();
  		else if (toBeParsed.equalsIgnoreCase("infinite")|| toBeParsed.equalsIgnoreCase("i"))
  			setToInfinite();
  		else if (toBeParsed.indexOf(".")>=0) {
  			setValue(MesquiteDouble.fromString(toBeParsed));
  		}
  		else {
  			try {
  				int d = Integer.parseInt(toBeParsed);
  				setValue(d);
  			}
  			catch (NumberFormatException e) {
  				try {
  					long d = Long.valueOf(toBeParsed).longValue();
  					setValue(d);
  				}
  				catch (NumberFormatException e2) {
  					setToUnassigned();
  				}
  			}
  		}
  	}
  	/*...........................................................*/
  	/** Sets the value to unassigned of this and auxiliaries */
  	public void deassignAllValues() {
  		setToUnassigned();
  		if (auxiliaries != null){
  			for (int i = 0; i< auxiliaries.length; i++)
  				auxiliaries[i].setToUnassigned();
  		}
  	}
  	/*...........................................................*/
  	/** Sets the value to unassigned */
  	public void setToUnassigned() {
  		if (watchpoint) MesquiteMessage.printStackTrace("MesquiteNumber changed value to unassigned");
  		unassignedFlag = true;
  		infiniteFlag = false;
  		intValue=MesquiteInteger.unassigned;
  		longValue=MesquiteLong.unassigned;
  		doubleValue=MesquiteDouble.unassigned;
  		valueClass =INT;
  	}
  	/*...........................................................*/
  	/** Sets the value to Infinity */
  	public void setToInfinite() {
  		if (watchpoint) MesquiteMessage.printStackTrace("MesquiteNumber changed value to infinity");
  		infiniteFlag = true;
  		unassignedFlag = false;
  		intValue=MesquiteInteger.infinite;
  		longValue=MesquiteLong.infinite;
  		doubleValue=MesquiteDouble.infinite;
  		valueClass =INT;
  	}
  	/*--------------------------------QUERY--------------------------*/
  	/** Returns true if value is unassigned */
  	public boolean isUnassigned() {
  		if (unassignedFlag)
  			return true;
  		else if (valueClass==INT) {
  			return intValue==MesquiteInteger.unassigned;
  		}
  		else if (valueClass == LONG) {
  			return longValue==MesquiteLong.unassigned;
  		}
  		else if (valueClass == DOUBLE) {
  			return doubleValue==MesquiteDouble.unassigned;
  		}
  		return false;
  	}
  	/** Returns true if value is infinite */
  	public boolean isInfinite() {
  		if (infiniteFlag)
  			return true;
  		else if (valueClass==INT) {
  			return intValue==MesquiteInteger.infinite;
  		}
  		else if (valueClass == LONG) {
  			return longValue==MesquiteLong.infinite;
  		}
  		else if (valueClass == DOUBLE) {
  			return doubleValue==MesquiteDouble.infinite;
  		}
  		return false;
  	}
  	/** Returns true if value is combinable (not unassigned, infinite, inapplicable, impossible) */
  	public boolean isCombinable() {
  		if (isUnassigned() || isInfinite())
  			return false;
  		else if (valueClass==INT) {
  			return (MesquiteInteger.isCombinable(intValue));
  		}
  		else if (valueClass == LONG) {
  			return (MesquiteLong.isCombinable(longValue));
  		}
  		else if (valueClass == DOUBLE) {
  			return (MesquiteDouble.isCombinable(doubleValue));
  		}
  		return false;
  	}
  	/** Returns true if value is combinable (not unassigned, infinite, inapplicable, impossible) */
  	public boolean isCombinable(int v) {
  		return (MesquiteInteger.isCombinable(v));
  	}
  	/** Returns true if value is combinable (not unassigned, infinite, inapplicable, impossible) */
  	public boolean isCombinable(long v) {
  		return (MesquiteLong.isCombinable(v));
  	}
  	/** Returns true if value is combinable (not unassigned, infinite, inapplicable, impossible) */
  	public boolean isCombinable(double v) {
  		return (MesquiteDouble.isCombinable(v));
  	}
  	/*...........................................................*/
  	/** Returns true if value is 0 */
  	public boolean isZero() {
  		if (isUnassigned() || isInfinite())
  			return false;
  		else if (valueClass==INT) {
  			return intValue==0;
  		}
  		else if (valueClass == LONG) {
  			return longValue==0;
  		}
  		else if (valueClass == DOUBLE) {
  			return doubleValue==0;
  		}
  		return false;
  	}
  	/*...........................................................*/
  	/** Returns true if value is negative */
  	public boolean isNegative() {
  		if (isUnassigned() || isInfinite())
  			return false;
  		else if (valueClass==INT) {
  			return intValue<0;
  		}
  		else if (valueClass == LONG) {
  			return longValue<0;
  		}
  		else if (valueClass == DOUBLE) {
  			return doubleValue<0;
  		}
  		return false;
  	}
  	/*...........................................................*/
  	/** Changes sign of value */
  	public void changeSign() {
  		if (isUnassigned() || isInfinite())
  			return;
  		else if (valueClass==INT) {
  			intValue = -intValue;
  		}
  		else if (valueClass == LONG) {
  			longValue = -longValue;
  		}
  		else if (valueClass == DOUBLE) {
  			doubleValue = -doubleValue;
  		}
  	}
  	/*--------------------------------ARITHMETICS--------------------------*/
  	/**  Sets to absolute value */
  	public void abs() {
  		if (valueClass==INT) {
  			intValue = Math.abs(intValue);
  		}
  		else if (valueClass == LONG)
  			longValue = Math.abs(longValue);
  		else if (valueClass == DOUBLE)
  			doubleValue = Math.abs(doubleValue);
  
  	}
  	/** Adds value to current value */
  	public void add(int toAdd) {
  		if (watchpoint) MesquiteMessage.printStackTrace("MesquiteNumber changed value (add)  " + toAdd);
  		if (valueClass==INT)
  			setValue(MesquiteInteger.add(intValue, toAdd));
  		else if (valueClass == LONG)
  			setValue(MesquiteLong.add(longValue, MesquiteLong.toLong(toAdd)));
  		else if (valueClass == DOUBLE)
  			setValue(MesquiteDouble.add(doubleValue, MesquiteDouble.toDouble(toAdd)));
  	}
  
  	/**  Adds value to current value */
  	public void add(long toAdd) {
  		if (watchpoint) MesquiteMessage.printStackTrace("MesquiteNumber changed value (add)  " + toAdd);
  		if (valueClass==INT)
  			setValue(MesquiteLong.add(MesquiteLong.toLong(intValue), toAdd));
  		else if (valueClass == LONG)
  			setValue(MesquiteLong.add(longValue, toAdd));
  		else if (valueClass == DOUBLE)
  			setValue(MesquiteDouble.add(doubleValue, MesquiteDouble.toDouble(toAdd)));
  	}
  
  	/**  Adds value to current value */
  	public void add(double toAdd) {
  		if (watchpoint) MesquiteMessage.printStackTrace("MesquiteNumber changed value (add)  " + toAdd);
  		if (valueClass==INT)
  			setValue(MesquiteDouble.add(MesquiteDouble.toDouble(intValue), toAdd));
  		else if (valueClass == LONG)
  			setValue(MesquiteDouble.add(MesquiteDouble.toDouble(longValue), toAdd));
  		else if (valueClass == DOUBLE)
  			setValue(MesquiteDouble.add(doubleValue, toAdd));
  	}
  	/**  Adds value to current value */
  	public void add(MesquiteNumber toAdd) {
  		if (watchpoint) MesquiteMessage.printStackTrace("MesquiteNumber changed value (add)  " + toAdd);
  		if (toAdd!=null) {
  			if (toAdd.valueClass==INT)
  				add(toAdd.intValue);
  			else if (toAdd.valueClass == LONG)
  				add(toAdd.longValue);
  			else if (toAdd.valueClass == DOUBLE)
  				add(toAdd.doubleValue);
  		}
  	}
  	/*...........................................................*/
  	/**  Subtracts value from current value */
  	public void subtract(int toSubtract) {  
  		if (watchpoint) MesquiteMessage.printStackTrace("MesquiteNumber changed value (subtract)  " + toSubtract);
  		if (valueClass==INT)
  			setValue(MesquiteInteger.subtract(intValue, toSubtract));
  		else if (valueClass == LONG)
  			setValue(MesquiteLong.subtract(longValue, MesquiteLong.toLong(toSubtract)));
  		else if (valueClass == DOUBLE)
  			setValue(MesquiteDouble.subtract(doubleValue, MesquiteDouble.toDouble(toSubtract)));
  	}
  
  	/**  Subtracts value from current value */
  	public void subtract(long toSubtract) { 
  		if (watchpoint) MesquiteMessage.printStackTrace("MesquiteNumber changed value (subtract)  " + toSubtract);
  		if (valueClass==INT)
  			setValue(MesquiteLong.subtract(MesquiteLong.toLong(intValue), toSubtract));
  		else if (valueClass == LONG)
  			setValue(MesquiteLong.subtract(longValue, toSubtract));
  		else if (valueClass == DOUBLE)
  			setValue(MesquiteDouble.subtract(doubleValue, MesquiteDouble.toDouble(toSubtract)));
  	}
  
  	/**  Subtracts value from current value */
  	public void subtract(double toSubtract) {
  		if (watchpoint) MesquiteMessage.printStackTrace("MesquiteNumber changed value (subtract)  " + toSubtract);
  		if (valueClass==INT)
  			setValue(MesquiteDouble.subtract(MesquiteDouble.toDouble(intValue), toSubtract));
  		else if (valueClass == LONG)
  			setValue(MesquiteDouble.subtract(MesquiteDouble.toDouble(longValue), toSubtract));
  		else if (valueClass == DOUBLE)
  			setValue(MesquiteDouble.subtract(doubleValue, toSubtract));
  	}
  	/**  Subtracts value from current value */
  	public void subtract(MesquiteNumber toSubtract) {
  		if (watchpoint) MesquiteMessage.printStackTrace("MesquiteNumber changed value (subtract)  " + toSubtract);
  		if (toSubtract!=null) {
  			if (toSubtract.valueClass==INT)
  				subtract(toSubtract.intValue);
  			else if (toSubtract.valueClass == LONG)
  				subtract(toSubtract.longValue);
  			else if (toSubtract.valueClass == DOUBLE)
  				subtract(toSubtract.doubleValue);
  		}
  	}
  	/*...........................................................*/
  	/** Multiplies current value by passed value */
  	public void multiplyBy(int toMultiply) {
  		if (watchpoint) MesquiteMessage.printStackTrace("MesquiteNumber changed value (multiplyBy)  " + toMultiply);
  		if (valueClass==INT)
  			setValue(MesquiteInteger.multiply(intValue, toMultiply));
  