jaroslav@49: /* jaroslav@49: * Copyright (c) 1994, 2001, Oracle and/or its affiliates. All rights reserved. jaroslav@49: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jaroslav@49: * jaroslav@49: * This code is free software; you can redistribute it and/or modify it jaroslav@49: * under the terms of the GNU General Public License version 2 only, as jaroslav@49: * published by the Free Software Foundation. Oracle designates this jaroslav@49: * particular file as subject to the "Classpath" exception as provided jaroslav@49: * by Oracle in the LICENSE file that accompanied this code. jaroslav@49: * jaroslav@49: * This code is distributed in the hope that it will be useful, but WITHOUT jaroslav@49: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jaroslav@49: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jaroslav@49: * version 2 for more details (a copy is included in the LICENSE file that jaroslav@49: * accompanied this code). jaroslav@49: * jaroslav@49: * You should have received a copy of the GNU General Public License version jaroslav@49: * 2 along with this work; if not, write to the Free Software Foundation, jaroslav@49: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jaroslav@49: * jaroslav@49: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA jaroslav@49: * or visit www.oracle.com if you need additional information or have any jaroslav@49: * questions. jaroslav@49: */ jaroslav@49: jaroslav@49: package java.lang; jaroslav@49: jaroslav@49: /** jaroslav@49: * The abstract class Number is the superclass of classes jaroslav@49: * BigDecimal, BigInteger, jaroslav@49: * Byte, Double, Float, jaroslav@49: * Integer, Long, and Short. jaroslav@49: *

jaroslav@49: * Subclasses of Number must provide methods to convert jaroslav@49: * the represented numeric value to byte, double, jaroslav@49: * float, int, long, and jaroslav@49: * short. jaroslav@49: * jaroslav@49: * @author Lee Boynton jaroslav@49: * @author Arthur van Hoff jaroslav@49: * @see java.lang.Byte jaroslav@49: * @see java.lang.Double jaroslav@49: * @see java.lang.Float jaroslav@49: * @see java.lang.Integer jaroslav@49: * @see java.lang.Long jaroslav@49: * @see java.lang.Short jaroslav@49: * @since JDK1.0 jaroslav@49: */ jaroslav@49: public abstract class Number implements java.io.Serializable { jaroslav@49: /** jaroslav@49: * Returns the value of the specified number as an int. jaroslav@49: * This may involve rounding or truncation. jaroslav@49: * jaroslav@49: * @return the numeric value represented by this object after conversion jaroslav@49: * to type int. jaroslav@49: */ jaroslav@49: public abstract int intValue(); jaroslav@49: jaroslav@49: /** jaroslav@49: * Returns the value of the specified number as a long. jaroslav@49: * This may involve rounding or truncation. jaroslav@49: * jaroslav@49: * @return the numeric value represented by this object after conversion jaroslav@49: * to type long. jaroslav@49: */ jaroslav@49: public abstract long longValue(); jaroslav@49: jaroslav@49: /** jaroslav@49: * Returns the value of the specified number as a float. jaroslav@49: * This may involve rounding. jaroslav@49: * jaroslav@49: * @return the numeric value represented by this object after conversion jaroslav@49: * to type float. jaroslav@49: */ jaroslav@49: public abstract float floatValue(); jaroslav@49: jaroslav@49: /** jaroslav@49: * Returns the value of the specified number as a double. jaroslav@49: * This may involve rounding. jaroslav@49: * jaroslav@49: * @return the numeric value represented by this object after conversion jaroslav@49: * to type double. jaroslav@49: */ jaroslav@49: public abstract double doubleValue(); jaroslav@49: jaroslav@49: /** jaroslav@49: * Returns the value of the specified number as a byte. jaroslav@49: * This may involve rounding or truncation. jaroslav@49: * jaroslav@49: * @return the numeric value represented by this object after conversion jaroslav@49: * to type byte. jaroslav@49: * @since JDK1.1 jaroslav@49: */ jaroslav@49: public byte byteValue() { jaroslav@49: return (byte)intValue(); jaroslav@49: } jaroslav@49: jaroslav@49: /** jaroslav@49: * Returns the value of the specified number as a short. jaroslav@49: * This may involve rounding or truncation. jaroslav@49: * jaroslav@49: * @return the numeric value represented by this object after conversion jaroslav@49: * to type short. jaroslav@49: * @since JDK1.1 jaroslav@49: */ jaroslav@49: public short shortValue() { jaroslav@49: return (short)intValue(); jaroslav@49: } jaroslav@49: jaroslav@49: /** use serialVersionUID from JDK 1.0.2 for interoperability */ jaroslav@49: private static final long serialVersionUID = -8742448824652078965L; jaroslav@49: }