home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / main.bin / Number.java < prev    next >
Text File  |  1997-05-20  |  4KB  |  114 lines

  1. /*
  2.  * @(#)Number.java    1.20 97/01/20
  3.  * 
  4.  * Copyright (c) 1995, 1996 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  * CopyrightVersion 1.1_beta
  20.  * 
  21.  */
  22.  
  23. package java.lang;
  24.  
  25. /**
  26.  * The abstract class <code>Number</code> is the superclass of 
  27.  * classes <code>Byte</code>, <code>Double</code>, <code>Float</code>,
  28.  * <code>Integer</code>, <code>Long</code>, and <code>Short</code>.
  29.  * <p>
  30.  * Subclasses of <code>Number</code> must provide methods to convert 
  31.  * the represented numeric value to <code>byte</code>, <code>double</code>,
  32.  * <code>float</code>, <code>int</code>, <code>long</code>, and
  33.  * <code>short</code>.
  34.  *
  35.  * @author    Lee Boynton
  36.  * @author    Arthur van Hoff
  37.  * @version 1.20, 01/20/97
  38.  * @see     java.lang.Byte
  39.  * @see     java.lang.Double
  40.  * @see     java.lang.Float
  41.  * @see     java.lang.Integer
  42.  * @see     java.lang.Long
  43.  * @see     java.lang.Short
  44.  * @since   JDK1.0
  45.  */
  46. public abstract class Number implements java.io.Serializable {
  47.     /**
  48.      * Returns the value of the specified number as an <code>int</code>.
  49.      * This may involve rounding.
  50.      *
  51.      * @return  the numeric value represented by this object after conversion
  52.      *          to type <code>int</code>.
  53.      * @since   JDK1.0
  54.      */
  55.     public abstract int intValue();
  56.  
  57.     /**
  58.      * Returns the value of the specified number as a <code>long</code>.
  59.      * This may involve rounding.
  60.      *
  61.      * @return  the numeric value represented by this object after conversion
  62.      *          to type <code>long</code>.
  63.      * @since   JDK1.0
  64.      */
  65.     public abstract long longValue();
  66.  
  67.     /**
  68.      * Returns the value of the specified number as a <code>float</code>.
  69.      * This may involve rounding.
  70.      *
  71.      * @return  the numeric value represented by this object after conversion
  72.      *          to type <code>float</code>.
  73.      * @since   JDK1.0
  74.      */
  75.     public abstract float floatValue();
  76.  
  77.     /**
  78.      * Returns the value of the specified number as a <code>double</code>.
  79.      * This may involve rounding.
  80.      *
  81.      * @return  the numeric value represented by this object after conversion
  82.      *          to type <code>double</code>.
  83.      * @since   JDK1.0
  84.      */
  85.     public abstract double doubleValue();
  86.  
  87.     /**
  88.      * Returns the value of the specified number as a <code>byte</code>.
  89.      * This may involve rounding or truncation.
  90.      *
  91.      * @return  the numeric value represented by this object after conversion
  92.      *          to type <code>byte</code>.
  93.      * @since   JDK1.1
  94.      */
  95.     public byte byteValue() {
  96.     return (byte)intValue();
  97.     }
  98.  
  99.     /**
  100.      * Returns the value of the specified number as a <code>short</code>.
  101.      * This may involve rounding or truncation.
  102.      *
  103.      * @return  the numeric value represented by this object after conversion
  104.      *          to type <code>short</code>.
  105.      * @since   JDK1.1
  106.      */
  107.     public short shortValue() {
  108.     return (short)intValue();
  109.     }
  110.  
  111.     /** use serialVersionUID from JDK 1.0.2 for interoperability */
  112.     private static final long serialVersionUID = -8742448824652078965L;
  113. }
  114.