2
|
1 |
/*
|
|
2 |
* Copyright 1994-2001 Sun Microsystems, Inc. All Rights Reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation. Sun designates this
|
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
|
9 |
* by Sun in the LICENSE file that accompanied this code.
|
|
10 |
*
|
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
* accompanied this code).
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License version
|
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
*
|
|
21 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
23 |
* have any questions.
|
|
24 |
*/
|
|
25 |
|
|
26 |
package java.lang;
|
|
27 |
|
|
28 |
/**
|
|
29 |
* The abstract class <code>Number</code> is the superclass of classes
|
|
30 |
* <code>BigDecimal</code>, <code>BigInteger</code>,
|
|
31 |
* <code>Byte</code>, <code>Double</code>, <code>Float</code>,
|
|
32 |
* <code>Integer</code>, <code>Long</code>, and <code>Short</code>.
|
|
33 |
* <p>
|
|
34 |
* Subclasses of <code>Number</code> must provide methods to convert
|
|
35 |
* the represented numeric value to <code>byte</code>, <code>double</code>,
|
|
36 |
* <code>float</code>, <code>int</code>, <code>long</code>, and
|
|
37 |
* <code>short</code>.
|
|
38 |
*
|
|
39 |
* @author Lee Boynton
|
|
40 |
* @author Arthur van Hoff
|
|
41 |
* @see java.lang.Byte
|
|
42 |
* @see java.lang.Double
|
|
43 |
* @see java.lang.Float
|
|
44 |
* @see java.lang.Integer
|
|
45 |
* @see java.lang.Long
|
|
46 |
* @see java.lang.Short
|
|
47 |
* @since JDK1.0
|
|
48 |
*/
|
|
49 |
public abstract class Number implements java.io.Serializable {
|
|
50 |
/**
|
|
51 |
* Returns the value of the specified number as an <code>int</code>.
|
|
52 |
* This may involve rounding or truncation.
|
|
53 |
*
|
|
54 |
* @return the numeric value represented by this object after conversion
|
|
55 |
* to type <code>int</code>.
|
|
56 |
*/
|
|
57 |
public abstract int intValue();
|
|
58 |
|
|
59 |
/**
|
|
60 |
* Returns the value of the specified number as a <code>long</code>.
|
|
61 |
* This may involve rounding or truncation.
|
|
62 |
*
|
|
63 |
* @return the numeric value represented by this object after conversion
|
|
64 |
* to type <code>long</code>.
|
|
65 |
*/
|
|
66 |
public abstract long longValue();
|
|
67 |
|
|
68 |
/**
|
|
69 |
* Returns the value of the specified number as a <code>float</code>.
|
|
70 |
* This may involve rounding.
|
|
71 |
*
|
|
72 |
* @return the numeric value represented by this object after conversion
|
|
73 |
* to type <code>float</code>.
|
|
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 |
*/
|
|
84 |
public abstract double doubleValue();
|
|
85 |
|
|
86 |
/**
|
|
87 |
* Returns the value of the specified number as a <code>byte</code>.
|
|
88 |
* This may involve rounding or truncation.
|
|
89 |
*
|
|
90 |
* @return the numeric value represented by this object after conversion
|
|
91 |
* to type <code>byte</code>.
|
|
92 |
* @since JDK1.1
|
|
93 |
*/
|
|
94 |
public byte byteValue() {
|
|
95 |
return (byte)intValue();
|
|
96 |
}
|
|
97 |
|
|
98 |
/**
|
|
99 |
* Returns the value of the specified number as a <code>short</code>.
|
|
100 |
* This may involve rounding or truncation.
|
|
101 |
*
|
|
102 |
* @return the numeric value represented by this object after conversion
|
|
103 |
* to type <code>short</code>.
|
|
104 |
* @since JDK1.1
|
|
105 |
*/
|
|
106 |
public short shortValue() {
|
|
107 |
return (short)intValue();
|
|
108 |
}
|
|
109 |
|
|
110 |
/** use serialVersionUID from JDK 1.0.2 for interoperability */
|
|
111 |
private static final long serialVersionUID = -8742448824652078965L;
|
|
112 |
}
|