home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / 3rdParty / jbuilder / unsupported / JDK1.2beta3 / SOURCE / SRC.ZIP / java / lang / Number.java < prev    next >
Encoding:
Java Source  |  1998-03-20  |  3.2 KB  |  102 lines

  1. /*
  2.  * @(#)Number.java    1.22 98/03/18
  3.  *
  4.  * Copyright 1994-1997 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.lang;
  16.  
  17. /**
  18.  * The abstract class <code>Number</code> is the superclass of 
  19.  * classes <code>Byte</code>, <code>Double</code>, <code>Float</code>,
  20.  * <code>Integer</code>, <code>Long</code>, and <code>Short</code>.
  21.  * <p>
  22.  * Subclasses of <code>Number</code> must provide methods to convert 
  23.  * the represented numeric value to <code>byte</code>, <code>double</code>,
  24.  * <code>float</code>, <code>int</code>, <code>long</code>, and
  25.  * <code>short</code>.
  26.  *
  27.  * @author    Lee Boynton
  28.  * @author    Arthur van Hoff
  29.  * @version 1.22, 03/18/98
  30.  * @see     java.lang.Byte
  31.  * @see     java.lang.Double
  32.  * @see     java.lang.Float
  33.  * @see     java.lang.Integer
  34.  * @see     java.lang.Long
  35.  * @see     java.lang.Short
  36.  * @since   JDK1.0
  37.  */
  38. public abstract class Number implements java.io.Serializable {
  39.     /**
  40.      * Returns the value of the specified number as an <code>int</code>.
  41.      * This may involve rounding.
  42.      *
  43.      * @return  the numeric value represented by this object after conversion
  44.      *          to type <code>int</code>.
  45.      */
  46.     public abstract int intValue();
  47.  
  48.     /**
  49.      * Returns the value of the specified number as a <code>long</code>.
  50.      * This may involve rounding.
  51.      *
  52.      * @return  the numeric value represented by this object after conversion
  53.      *          to type <code>long</code>.
  54.      */
  55.     public abstract long longValue();
  56.  
  57.     /**
  58.      * Returns the value of the specified number as a <code>float</code>.
  59.      * This may involve rounding.
  60.      *
  61.      * @return  the numeric value represented by this object after conversion
  62.      *          to type <code>float</code>.
  63.      */
  64.     public abstract float floatValue();
  65.  
  66.     /**
  67.      * Returns the value of the specified number as a <code>double</code>.
  68.      * This may involve rounding.
  69.      *
  70.      * @return  the numeric value represented by this object after conversion
  71.      *          to type <code>double</code>.
  72.      */
  73.     public abstract double doubleValue();
  74.  
  75.     /**
  76.      * Returns the value of the specified number as a <code>byte</code>.
  77.      * This may involve rounding or truncation.
  78.      *
  79.      * @return  the numeric value represented by this object after conversion
  80.      *          to type <code>byte</code>.
  81.      * @since   JDK1.1
  82.      */
  83.     public byte byteValue() {
  84.     return (byte)intValue();
  85.     }
  86.  
  87.     /**
  88.      * Returns the value of the specified number as a <code>short</code>.
  89.      * This may involve rounding or truncation.
  90.      *
  91.      * @return  the numeric value represented by this object after conversion
  92.      *          to type <code>short</code>.
  93.      * @since   JDK1.1
  94.      */
  95.     public short shortValue() {
  96.     return (short)intValue();
  97.     }
  98.  
  99.     /** use serialVersionUID from JDK 1.0.2 for interoperability */
  100.     private static final long serialVersionUID = -8742448824652078965L;
  101. }
  102.