jdk/src/share/classes/java/lang/Number.java
author martin
Mon, 10 Mar 2008 14:32:51 -0700
changeset 48 dc5744ca15ea
parent 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
4960438: (process) Need IO redirection API for subprocesses Reviewed-by: alanb, iris
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1994-2001 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.lang;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * The abstract class <code>Number</code> is the superclass of classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * <code>BigDecimal</code>, <code>BigInteger</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * <code>Byte</code>, <code>Double</code>, <code>Float</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * <code>Integer</code>, <code>Long</code>, and <code>Short</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * Subclasses of <code>Number</code> must provide methods to convert
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * the represented numeric value to <code>byte</code>, <code>double</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * <code>float</code>, <code>int</code>, <code>long</code>, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * <code>short</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * @author      Lee Boynton
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * @author      Arthur van Hoff
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * @see     java.lang.Byte
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * @see     java.lang.Double
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * @see     java.lang.Float
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * @see     java.lang.Integer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * @see     java.lang.Long
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * @see     java.lang.Short
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * @since   JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
public abstract class Number implements java.io.Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     * Returns the value of the specified number as an <code>int</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     * This may involve rounding or truncation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * @return  the numeric value represented by this object after conversion
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     *          to type <code>int</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    public abstract int intValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * Returns the value of the specified number as a <code>long</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * This may involve rounding or truncation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * @return  the numeric value represented by this object after conversion
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     *          to type <code>long</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    public abstract long longValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * Returns the value of the specified number as a <code>float</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * This may involve rounding.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * @return  the numeric value represented by this object after conversion
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     *          to type <code>float</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    public abstract float floatValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * Returns the value of the specified number as a <code>double</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * This may involve rounding.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * @return  the numeric value represented by this object after conversion
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     *          to type <code>double</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    public abstract double doubleValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * Returns the value of the specified number as a <code>byte</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * This may involve rounding or truncation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * @return  the numeric value represented by this object after conversion
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     *          to type <code>byte</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * @since   JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    public byte byteValue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        return (byte)intValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * Returns the value of the specified number as a <code>short</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * This may involve rounding or truncation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * @return  the numeric value represented by this object after conversion
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     *          to type <code>short</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * @since   JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    public short shortValue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        return (short)intValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    /** use serialVersionUID from JDK 1.0.2 for interoperability */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    private static final long serialVersionUID = -8742448824652078965L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
}