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

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