/*
 * Jakelib2 - General purpose C++ library
 * Copyright (C) 2001 Florian Wolff  (florian@donuz.de)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * $Id: Float.h,v 1.1 2003/01/11 10:05:02 florian Exp $
 */

#ifndef INCLUDE_JAKELIB2_LANG_FLOAT_H
# define INCLUDE_JAKELIB2_LANG_FLOAT_H
# include "Number.h"

namespace jakelib {
  namespace lang {

    /**
     * An instance of this class encapsulates a single \c jfloat value.
     * \c Float objects can be used as hash keys for example.
     * Some class methods provide functions to convert strings to floats 
     * and vice versa.
     *
     * @class Float
     * @version $Id: Float.h,v 1.1 2003/01/11 10:05:02 florian Exp $
     * @author Florian 'Overflo' Wolff (florian@donuz.de)
     */
    class Float : public Number, Comparable
      {
      private:
	/** @brief The actual \c jfloat value */
	jfloat value;

      public:
	/**
	 * @brief Creates a new \c Float object with the given \c jfloat value.
	 */
	Float(jfloat value);

	/**
	 * @brief Creates a new \c Float object. The given \c String is
	 * parsed and converted to \c jfloat.
	 *
	 * @throws NumberFormatException If the \c String cannot be parsed
	 */
	Float(String* s);
  
	/**
	 * @brief Returns a hashcode for the Float value. 
	 *
	 * @return hash code
	 */
	jint hashCode();
  
	/**
	 * @brief Returns the string representation of the Float value.
	 *
	 * @return String representation
	 */
	String* toString();
  
	/**
	 * @brief Returns the string representation of the given Float value.
	 *
	 * @param value Float value.
	 * @return String representation
	 */
	static String* toString(jfloat value);
  
	/**
	 * Compares this object to the specified object.
	 *
	 * The result is <code>true</code> if and only if the argument is not
	 * <code>null</code> and is an <code>Float</code> object that contains
	 * the same <code>jFloat</code> value as this object.
	 *
	 * @param   obj   the object to compare with.
	 * @return  <code>true</code> if the objects are the same;
	 *          <code>false</code> otherwise.
	 */
	jboolean equals(Object* obj);
    
	/**
	 * @brief Returns the number represented by this object converted to <tt>jbyte</tt>.
	 */
	jbyte byteValue();

	/**
	 * @brief Returns the number represented by this object converted to <tt>jdouble</tt>.
	 */
	jdouble doubleValue();

	/**
	 * @brief Returns the number represented by this object converted to <tt>jfloat</tt>.
	 */
	jfloat floatValue();

	/**
	 * @brief Returns the number represented by this object converted to <tt>jint</tt>.
	 */
	jint intValue();

	/**
	 * @brief Returns the number represented by this object converted to <tt>jlong</tt>.
	 */
	jlong longValue();

	/**
	 * @brief Returns the number represented by this object converted to <tt>jshort</tt>.
	 */
	jshort shortValue();

	/**
	 *
	 * @throws NumberFormatException If the \c String cannot be parsed
	 */
	static Float* valueOf(String* str);

	/**
	 *
	 * @throws NumberFormatException If the \c String cannot be parsed
	 */
	static jfloat parseFloat(String* str);

	/**
	 *
	 * @throws NumberFormatException If the string cannot be parsed
	 */
	static jfloat parseFloat(const char* str);
  
	int compareTo(Float* obj);
	int compareTo(Object* obj);

	static const jfloat MAX_VALUE;
	static const jfloat MIN_VALUE;

	JAKELIB_DECLARE_CLASS(Float);
      };

  }
}

#endif

