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