/[classpath]/classpath/java/lang/Number.java
ViewVC logotype

Diff of /classpath/java/lang/Number.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by mark, Tue Jan 22 22:27:00 2002 UTC revision 1.7 by ericb, Mon Feb 25 01:36:03 2002 UTC
# Line 1  Line 1 
1  /* java.lang.Number  /* Number.java =- abstract superclass of numeric objects
2     Copyright (C) 1998, 2001 Free Software Foundation, Inc.     Copyright (C) 1998, 2001, 2002 Free Software Foundation, Inc.
3    
4  This file is part of GNU Classpath.  This file is part of GNU Classpath.
5    
# Line 7  GNU Classpath is free software; you can Line 7  GNU Classpath is free software; you can
7  it under the terms of the GNU General Public License as published by  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2, or (at your option)  the Free Software Foundation; either version 2, or (at your option)
9  any later version.  any later version.
10    
11  GNU Classpath is distributed in the hope that it will be useful, but  GNU Classpath is distributed in the hope that it will be useful, but
12  WITHOUT ANY WARRANTY; without even the implied warranty of  WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Line 41  package java.lang; Line 41  package java.lang;
41  import java.io.Serializable;  import java.io.Serializable;
42    
43  /**  /**
44   ** Number is a generic superclass of all the numeric classes, namely   * Number is a generic superclass of all the numeric classes, including
45   ** <code>Byte</code>, <code>Short</code>, <code>Integer</code>,   * the wrapper classes {@link Byte}, {@link Short}, {@link Integer},
46   ** <code>Long</code>, <code>Float</code>, and <code>Double</code>.   * {@link Long}, {@link Float}, and {@link Double}.  Also worth mentioning
47   **   * are the classes in {@link java.math}.
48   ** It provides ways to convert from any one value to any other.   *
49   **   * It provides ways to convert numeric objects to any primitive.
50   ** @author Paul Fisher   *
51   ** @author John Keiser   * @author Paul Fisher
52   ** @author Warren Levy   * @author John Keiser
53   ** @since JDK1.0   * @author Warren Levy
54   **/   * @author Eric Blake <ebb9@email.byu.edu>
55     * @since 1.0
56     * @status updated to 1.4
57     */
58  public abstract class Number implements Serializable  public abstract class Number implements Serializable
59  {  {
60    /** Return the value of this <code>Number</code> as a <code>byte</code>.    /**
61     ** @return the value of this <code>Number</code> as a <code>byte</code>.     * Compatible with JDK 1.1+.
62     **/     */
63    public byte byteValue()    private static final long serialVersionUID = -8742448824652078965L;
   {  
     return (byte) intValue();  
   }  
64    
65    /** Return the value of this <code>Number</code> as a <code>short</code>.    /**
66     ** @return the value of this <code>Number</code> as a <code>short</code>.     * The basic constructor (often called implicitly).
67     **/     */
68    public short shortValue()    public Number()
69    {    {
     return (short) intValue();  
70    }    }
71    
72    /** Return the value of this <code>Number</code> as an <code>int</code>.    /**
73     ** @return the value of this <code>Number</code> as an <code>int</code>.     * Return the value of this <code>Number</code> as an <code>int</code>.
74     **/     *
75       * @return the int value
76       */
77    public abstract int intValue();    public abstract int intValue();
78    
79    /** Return the value of this <code>Number</code> as a <code>long</code>.    /**
80     ** @return the value of this <code>Number</code> as a <code>long</code>.     * Return the value of this <code>Number</code> as a <code>long</code>.
81     **/     *
82       * @return the long value
83       */
84    public abstract long longValue();    public abstract long longValue();
85    
86    /** Return the value of this <code>Number</code> as a <code>float</code>.    /**
87     ** @return the value of this <code>Number</code> as a <code>float</code>.     * Return the value of this <code>Number</code> as a <code>float</code>.
88     **/     *
89       * @return the float value
90       */
91    public abstract float floatValue();    public abstract float floatValue();
92    
93    /** Return the value of this <code>Number</code> as a <code>float</code>.    /**
94     ** @return the value of this <code>Number</code> as a <code>float</code>.     * Return the value of this <code>Number</code> as a <code>float</code>.
95     **/     *
96       * @return the double value
97       */
98    public abstract double doubleValue();    public abstract double doubleValue();
99    
100    private static final long serialVersionUID = -8742448824652078965L;    /**
101       * Return the value of this <code>Number</code> as a <code>byte</code>.
102       *
103       * @return the byte value
104       * @since 1.1
105       */
106      public byte byteValue()
107      {
108        return (byte) intValue();
109      }
110    
111      /**
112       * Return the value of this <code>Number</code> as a <code>short</code>.
113       *
114       * @return the short value
115       * @since 1.1
116       */
117      public short shortValue()
118      {
119        return (short) intValue();
120      }
121  }  }

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26