JDK1.8 API翻譯(第三彈:Number)

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章