// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3) fieldsfirst 
// Source File Name:   ConstantNode.java

package lt.monarch.function.node;

import lt.monarch.function.Node;
import lt.monarch.function.NodeCompiler;

// Referenced classes of package lt.monarch.function.node:
//			AbstractNode, TermNode

public class ConstantNode extends AbstractNode
	implements TermNode
{

	private double value;

	public Node cloneNode()
	{
		return (Node)new ConstantNode(value);
	}

	public String toString()
	{
		String s = String.valueOf(value);
		if(value == Math.floor(value))
			s = String.valueOf((int)value);
		return value >= 0.0D ? s : "(" + s + ")";
	}

	public double evaluate()
	{
		return value;
	}

	public boolean equals(Object obj)
	{
		return super.equals(obj) && value == ((ConstantNode)obj).value;
	}

	public double multiplier()
	{
		return value;
	}

	public Node termNode()
	{
		return null;
	}

	public void compile(NodeCompiler nodecompiler)
	{
		nodecompiler.appendConst(value);
	}

	public ConstantNode(double d)
	{
		value = d;
	}
}
