001/*
002 * This file is part of OCaml-Java runtime.
003 * Copyright (C) 2007-2013 Xavier Clerc.
004 *
005 * OCaml-Java runtime is free software; you can redistribute it and/or modify
006 * it under the terms of the GNU Lesser General Public License as published by
007 * the Free Software Foundation; either version 3 of the License, or
008 * (at your option) any later version.
009 *
010 * OCaml-Java runtime is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
013 * GNU Lesser General Public License for more details.
014 *
015 * You should have received a copy of the GNU Lesser General Public License
016 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
017 */
018
019package org.ocamljava.runtime.wrappers;
020
021import org.ocamljava.runtime.values.Value;
022
023/**
024 * The {@code OCamlNumber} interface is similar to the
025 * {@code java.lang.Number} class, thus allowing to manipulate OCaml
026 * values wrapping numeric values in the same way as classical Java
027 * wrappers for primitive types.
028 *
029 * @see java.lang.Number
030 *
031 * @author <a href="mailto:xclerc@ocamljava.org">Xavier Clerc</a>
032 * @version 2.0
033 * @since 2.0
034 */
035public interface OCamlNumber {
036
037    /**
038     * Returns the wrapped value as a {@code byte}, rounding and/or
039     * truncating it if necessary.
040     * @return the wrapped value, converted to a {@code byte}
041     */
042    byte byteValue();
043
044    /**
045     * Returns the wrapped value as a {@code double}, rounding and/or
046     * truncating it if necessary.
047     * @return the wrapped value, converted to a {@code double}
048     */
049    double doubleValue();
050
051    /**
052     * Returns the wrapped value as a {@code float}, rounding and/or
053     * truncating it if necessary.
054     * @return the wrapped value, converted to a {@code float}
055     */
056    float floatValue();
057
058    /**
059     * Returns the wrapped value as a {@code int}, rounding and/or
060     * truncating it if necessary.
061     * @return the wrapped value, converted to a {@code int}
062     */
063    int intValue();
064
065    /**
066     * Returns the wrapped value as a {@code long}, rounding and/or
067     * truncating it if necessary.
068     * @return the wrapped value, converted to a {@code long}
069     */
070    long longValue();
071
072    /**
073     * Returns the wrapped value as a {@code short}, rounding and/or
074     * truncating it if necessary.
075     * @return the wrapped value, converted to a {@code short}
076     */
077    short shortValue();
078
079} // end interface 'Number'