//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// PLEASE DO NOT EDIT WITHOUT THE EXPLICIT CONSENT OF THE AUTHOR! \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\

package ilog.language.design.kernel;

/**
 * @version     Last modified on Wed Jul 24 12:19:21 2002 by pviry
 * @version          modified on Fri Mar 08 12:37:12 2002 by hak
 * @author      <a href="mailto:hak@ilog.fr">Hassan A&iuml;t-Kaci</a>
 * @copyright   &copy; 2000-2002 <a href="http://www.ilog.fr/">ILOG, S.A.</a>
 */

import ilog.language.design.types.*;
import ilog.language.design.base.*;

/**
 * This is the class of boxed real numbers.
 */
public class Real extends Constant
{
  private double _value;

  public Real (double value, boolean flag)
    {
      if (flag)
        _type = Type.REAL;
      else
        _type = Type.REAL();      
      _setValue(value);
    }

  public Real (double value)
    {
      super(Type.REAL());
      _setValue(value);
    }

  public final double value ()
    {
      return _value;
    }

  private final void _setValue (double value)
    {
      _value = value;
      if (value == 0.0) setIsNull();
    }

  public final void compile (Compiler compiler)
    {
      compiler.generate(new PushValueReal(_value));
    }

  public final boolean equals (Object other)
    {
      if (!(other instanceof Real))
        return false;
      
      return _value == ((Real)other).value();
    }

  public final String toString ()
    {
      return String.valueOf(_value);
      //      return "<"+_value+">";
    }

  // Added by PV
  public final String toTypedString ()
    {
        return typed(String.valueOf(_value));
    }
}
