2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
22 * The abstract superclass of the classes which represent numeric base types
23 * (that is {@link Byte}, {@link Short}, {@link Integer}, {@link Long},
24 * {@link Float}, and {@link Double}.
26 public abstract class Number implements java.io.Serializable {
28 private static final long serialVersionUID = -8742448824652078965L;
31 * Empty default constructor.
37 * Returns this object's value as a byte. Might involve rounding and/or
38 * truncating the value, so it fits into a byte.
40 * @return the primitive byte value of this object.
42 public byte byteValue() {
43 return (byte) intValue();
47 * Returns this object's value as a double. Might involve rounding.
49 * @return the primitive double value of this object.
51 public abstract double doubleValue();
54 * Returns this object's value as a float. Might involve rounding.
56 * @return the primitive float value of this object.
58 public abstract float floatValue();
61 * Returns this object's value as an int. Might involve rounding and/or
62 * truncating the value, so it fits into an int.
64 * @return the primitive int value of this object.
66 public abstract int intValue();
69 * Returns this object's value as a long. Might involve rounding and/or
70 * truncating the value, so it fits into a long.
72 * @return the primitive long value of this object.
74 public abstract long longValue();
77 * Returns this object's value as a short. Might involve rounding and/or
78 * truncating the value, so it fits into a short.
80 * @return the primitive short value of this object.
82 public short shortValue() {
83 return (short) intValue();