API文档链接如下:
https://docs.oracle.com/javase/8/docs/api/java/lang/Number.html
下面开始翻译。
Class Number
java.lang.Object
java.lang.Number
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
AtomicInteger, AtomicLong, BigDecimal, BigInteger, Byte, Double, DoubleAccumulator, DoubleAdder, Float, Integer, Long, LongAccumulator, LongAdder, Short
public abstract class Number
extends Object
implements Serializable
The abstract class Number is the superclass of platform classes representing numeric values that are convertible to the primitive types byte, double, float, int, long, and short. The specific semantics of the conversion from the numeric value of a particular Number implementation to a given primitive type is defined by the Number implementation in question. For platform classes, the conversion is often analogous to a narrowing primitive conversion or a widening primitive conversion as defining in The Java Language Specification for converting between primitive types. Therefore, conversions may lose information about the overall magnitude of a numeric value, may lose precision, and may even return a result of a different sign than the input. See the documentation of a given Number implementation for conversion details.
抽象类Number是一些表示数字值的类的父类,这些类可转换为byte, double, float, int, long, short这些基本数据类型。从一个特定的Number实现的数字值到一个给定的基本类型的转换的语义是由这个Number实现定义的。对于平台类,转换往往是类似于缩窄原始转换或扩展原始转换,像Java语言规范中定义的基本类型之间的转换一样。 因此,转换可能会丢失有关数值总体大小的信息,可能会丢失精度,甚至可能会返回与输入不同的正负号结果。转换的详细信息,参阅给定的Number实现的文档。
Since:
JDK1.0
See Also:
Serialized Form
See The Java Language Specification:
5.1.2 Widening Primitive Conversions, 5.1.3 Narrowing Primitive Conversions
Number
public Number()
intValue
public abstract int intValue()
Returns the value of the specified number as an int, which may involve rounding or truncation.
返回指定数字的值为int ,可能产生四舍五入或截断。
Returns:
the numeric value represented by this object after conversion to type int.
该对象在转换为int之后所表示的数字值。
longValue
public abstract long longValue()
Returns the value of the specified number as a long, which may involve rounding or truncation.
返回指定数字的值为long ,可能产生四舍五入或截断。
Returns:
the numeric value represented by this object after conversion to type long.
该对象在转换为long之后所表示的数字值。
floatValue
public abstract float floatValue()
Returns the value of the specified number as a float, which may involve rounding.
返回指定数字的值为float ,可能产生四舍五入。
Returns:
the numeric value represented by this object after conversion to type float.
该对象在转换为float之后所表示的数字值。
doubleValue
public abstract double doubleValue()
Returns the value of the specified number as a double, which may involve rounding.
返回指定数字的值为double,可能产生四舍五入。
Returns:
the numeric value represented by this object after conversion to type double.
该对象在转换为double之后所表示的数字值。
byteValue
public byte byteValue()
Returns the value of the specified number as a byte, which may involve rounding or truncation.
This implementation returns the result of intValue() cast to a byte.
返回指定数字的值为byte ,可能产生四舍五入或截断。
这个实现返回intValue()转换为byte后的结果。
Returns:
the numeric value represented by this object after conversion to type byte.
该对象在转换为byte之后所表示的数字值。
Since:
JDK1.1
shortValue
public short shortValue()
Returns the value of the specified number as a short, which may involve rounding or truncation.
This implementation returns the result of intValue() cast to a short.
返回指定数字的值为short,可能产生四舍五入或截断。
这个实现返回intValue()转换为short后的结果。
Returns:
the numeric value represented by this object after conversion to type short.
该对象在转换为short之后所表示的数字值。
Since:
JDK1.1