/**
 * 
 */
package dspl.intermediate.variable;

/**
 * DSPLFloat is the Variable class for the float primitive
 * @author David
 */
public class DSPLFloat extends Variable {
	/* (non-Javadoc)
	 * @see dspl.intermediate.variable.Variable#Variable(int)
	 */
	public DSPLFloat(int numElements) {
		super(numElements);
	}

	/* (non-Javadoc)
	 * @see dspl.intermediate.variable.Variable#isNumeric()
	 */
	public boolean isNumeric() {
		return true;
	}

	/* (non-Javadoc)
	 * @see dspl.intermediate.variable.Variable#getByteSize()
	 */
	public int getDataTypeByteSize() {
		return 4; 
	}

	/* (non-Javadoc)
	 * @see dspl.intermediate.variable.Variable#getVariableDataType()
	 */
	public int getDataType() {
		return Variable.DATA_TYPE_FLOAT;
	}

	/* (non-Javadoc)
	 * @see dspl.intermediate.variable.Variable#convertToObject(java.lang.String)
	 */
	public Object convertToObject(String strValue) {
		Double myDouble = new Double(strValue); 
		if(myDouble.isInfinite() || myDouble.isNaN())
			throw new NumberFormatException("Value " + strValue + " is too large for float");
		return myDouble;
	}

	/* (non-Javadoc)
	 * @see dspl.intermediate.variable.Variable#convertToObject(java.lang.String,java.lang.String)
	 */
	public Object convertToObject(String strValue1, String strValue2) {
		throw new Error("Error: convertToObject(String, String) called on " + this.getClass().toString()); 
	}
	
	/* (non-Javadoc)
	 * @see dspl.intermediate.variable.Variable#isNaturalNum
	 */
	public boolean isNaturalNum() {
		return false; 
	}
}
