/* * @(#)Number.java 1.29 03/12/19 * * Copyright 2004 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ 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 * @version 1.29, 12/19/03 * @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; }