JDK1.8 The Java® Virtual Machine Specification《2.The Structure of the Java Virtual Mach》(2)

 

2.3.1 (积分)指数表达类型值

整型类型在虚拟机中的值表现为

byte-128到127-2^7 to 2^7 - 1
short-32768到32767-2^15 to 2^15 - 1
int-2147483648到2147483647-2^31 to 2^31 - 1
long从-9223372036854775808到9223372036854775807-2^63 to 2^63 - 1
char0到65535--

 

2.3.2 浮点类型,值集 与 值

浮点数就是指32位的单精度浮点数float和双精度64位的double,他们的格式与IEEE754定义的float

和double是近乎相通的,而且对数值的操作与IEEE规定的标准二进制浮点数计算方式相关。IEEE 754 标准不仅包含正负符号幅度数,而且包含正负零,正负无穷数以及NaN(一个非数字值 Not a Number的简称),NaN这个值被用来表示表示无效操作的结果,例如零除以零....

每一个java虚拟机的实现中都需要用到两种标准的浮点集,他们是浮点值集和倍精度数値集合。除此之外一个java虚拟机的实现也许会根据自身设置,提供扩展指数浮点数集和扩展指数双浮点数集中的任意一个或全部(也不知道翻译的正不正确 called the float-extended-exponent value setand the double-extended-exponent value set.)。在某些情况下,这些扩展指数值集会替代标准值集去表示float和double类型的值。

任何浮点类型的有限非零值可以表达成如下公式s ⋅ m ⋅ 2^(e − N + 1)    其中s表示+1或者-1, m是一个小于2N的正整数,e是一个介于之间的整数,并且N 和 K 是取决于值集的参数。有些数值可能有多种展现方式。

(说实话下面的话真不太懂)

例如,假设值集中的值 V 可能使用 s,m 和 e 的某些值(不明白),如果 m为偶数并且 e小于2^(K -1),则可以减半 m并将 e增加1以产生相同值 v(one could halve m and increase e by 1 to produce a second representation for the same value v.)。如果m ≥ 2 ^(N-1),则这种形式被称为归一化; 否则该表示被称为非规范化。如果在一个值集下的值不能用m ≥ 2 ^(N -1)的方式来表示,之后该值被认为是一个非标准化的值,因为它没有归一化表示。

下表总结了两个必需的浮点值集和两个可选浮点值集的参数NK(以及推导参数 E min和E max) 的约束条件。

表2.3.2-A。浮点值设置参数

参数浮点精度浮扩展-指数双浮点精度双扩展指数
N24245353
K8≥ 1111≥ 15
E max+127≥+ 1023+1023≥ + 16383
E min-126≤- 1022-1022≤- 16382

 

。。。

Note that the constraints in Table 2.3.2-A are designed so that every element of the float value set is necessarily also an element of the float-extended-exponent value set, the double value set, and the double-extended-exponent value set. Likewise, each element of the double value set is necessarily also an element of the double-extended-exponent value set. Each extended-exponent value set has a larger range of exponent values than the corresponding standard value set, but does not have more precision.

The elements of the float value set are exactly the values that can be represented using the single floating-point format defined in the IEEE 754 standard, except that there is only one NaN value (IEEE 754 specifies 224-2 distinct NaN values). The elements of the double value set are exactly the values that can be represented using the double floating-point format defined in the IEEE 754 standard, except that there is only one NaN value (IEEE 754 specifies 253-2 distinct NaN values). Note, however, that the elements of the float-extended-exponent and double-extended-exponent value sets defined here do notcorrespond to the values that can be represented using IEEE 754 single extended and double extended formats, respectively. This specification does not mandate a specific representation for the values of the floating-point value sets except where floating-point values must be represented in the class file format (§4.4.4§4.4.5).

。。。

float,float-extended-exponent,double和double-extended-exponent值集不是一个类型(???不明白)。对于Java虚拟机的实现来说使用float值集的元素来表示的float; 但是,在某些上下文中可能允许实现使用float-extended-exponent值集的元素。类似地,使用double值集的元素来表示double; 但是,在某些上下文中,可能允许实现使用双扩展指数值集的元素。

除NaNs外,浮点值集的值是有序的。当从小到大排列时,它们分别是负无穷大<负有限值<正负零<正有限值<正无穷大。

比较正浮点零和负浮点零两个数,他们其实是相等的,但还有其他操作可以区分它们; 例如,通过0.0除以1.0会产生正无穷大,但通过-0.0除以1.0 产生负无穷大。( dividing 1.0 by 0.0 produces positive infinity, but dividing 1.0 by -0.0 produces negative infinity.)

NaNs是无序的,如果其操作数中的任何一个或两个都是NaN ,则数值比较的操作和数值相等的测试都会产生false的结果。特别是,当且仅当值为NaN时,对值自身的数值相等性的测试会产生false的结果。如果任一操作数是NaN,则对数值不等式的测试会产生true的结果。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值