public abstract class Number extends Object implements Serializable
Number
表示数值转换为原始类型
byte
,
double
,
float
,
int
,
long
,和
short
父类。从一个特定的
Number
实现数值给定的原始类型转换的具体语义是由实现定义的
Number
问题。平台类的转换往往是类似于一个窄化转换或扩大基本转换为定义在
The Java™ Language Specification之间的原始类型转换。因此,转换可能会丢失一个数字值的整体大小的信息,可能会失去精度,甚至可能会返回一个不同的符号比输入的结果。看到一个给定的转换细节
Number
执行文件。
Constructor and Description |
---|
Number() |
Modifier and Type | Method and Description |
---|---|
byte |
byteValue()
作为一个
byte 返回指定数字的值,这可能涉及舍入或截断。
|
abstract double |
doubleValue()
作为一个
double 返回指定数字的值,这可能涉及舍入。
|
abstract float |
floatValue()
作为一个
float 返回指定数字的值,这可能涉及舍入。
|
abstract int |
intValue()
作为一个
int 返回指定数字的值,这可能涉及舍入或截断。
|
abstract long |
longValue()
作为一个
long 返回指定数字的值,这可能涉及舍入或截断。
|
short |
shortValue()
作为一个
short 返回指定数字的值,这可能涉及舍入或截断。
|
public abstract int intValue()
int
返回指定数字的值,这可能涉及舍入或截断。
int
后。
public abstract long longValue()
long
返回指定数字的值,这可能涉及舍入或截断。
long
后。
public abstract float floatValue()
float
返回指定数字的值,这可能涉及舍入。
float
后。
public abstract double doubleValue()
double
返回指定数字的值,这可能涉及舍入。
double
后。
public byte byteValue()
byte
返回指定数字的值,这可能涉及舍入或截断。
此实现返回intValue()
将结果一byte
。
byte
后。
public short shortValue()
short
返回指定数字的值,这可能涉及舍入或截断。
此实现返回intValue()
将结果一short
。
short
后。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.