当前位置: 代码迷 >> 综合 >> ECMA-262, 9th edition部分译文之chapter 6 part1
  详细解决方案

ECMA-262, 9th edition部分译文之chapter 6 part1

热度:15   发布时间:2023-12-04 23:46:25.0

最近比较忙,时不时翻译点儿,这是第6部分语言数据类型内容第一部分——数值类型

6 ECMAScript Data Types and Values

6.1 ECMAScript Language Types(ECMAScript 语言类型,即实际编程中使用的类型,区别后面的规范类型)

6.1.6 The Number Type

原文:The Number type has exactly 18437736874454810627 (that is, 2^64-2^53+3) values, representing the double-precision 64-bit format IEEE 754-2008 values as specified in the IEEE Standard for Binary Floating-Point Arithmetic, except that the 9007199254740990 (that is, 2^53-2) distinct “Not-a-Number” values of the IEEE Standard are represented in ECMAScript as a single special NaN value. (Note that the NaN value is produced by the program expression NaN.) In some implementations, external code might be able to detect a difference between various Not-a-Number values, but such behaviour is implementation-dependent; to ECMAScript code, all NaN values are indistinguishable from each other.

译文:ECMA的数字类型精确的一共有18437736874454810627个值,通过IEEE 754-2008的标准表述为双精度的64位浮点数,除了 9007199254740990个特殊的在IEEE中称为“Not-a-Number”的值在ECMA中表述为单一一个“NaN”值(该值通过NaN表达式创建);在某些实现中,外部代码可能能够检测到各种“Not-a-Number”值中的不同,但是这种行为是一种实现依赖型的,依赖于不同的实现可能。在ECMA中,所有的NaN值彼此间是不能够区分的。

 

原文:There are two other special values, called positive Infinity and negative Infinity. For brevity, these values are also referred to for expository purposes by the symbols +∞ and -∞, respectively. (Note that these two infinite Number values are produced by the program expressions +Infinity (or simply Infinity) and -Infinity.)

译文:还有两个特殊的值,是正无穷和负无穷,为了简洁表示,通常这两个值也分别通过符号+∞ 和 -∞表示(这两个无穷值,通过+Infinity (或者 Infinity) 和 -Infinity表达式创建)

 

原文:The other 18437736874454810624 (that is, 2^64-2^53) values are called the finite numbers. Half of these are positive numbers and half are negative numbers; for every finite positive Number value there is a corresponding negative value having the same magnitude.

译文:其他18437736874454810624个值称为有限数字,一半为正数,一半为负数。每一个有限的正数值都有一个在数量级上与之对应的负数值。

 

原文:Note that there is both a positive zero and a negative zero. For brevity, these values are also referred to for expository purposes by the symbols +0 and -0, respectively. (Note that these two different zero Number values are produced by the program expressions +0 (or simply 0) and -0.)

译文:注意在这其中是包含正0和负0的,简化表示为+0,-0(这两个值分别通过+0(或0)和-0表达式创建)

 

原文:The 18437736874454810622 (that is, 2^64-2^53-2) finite nonzero values are of two kinds:

18428729675200069632 (that is, 2^64-2^54) of them are normalized, having the form

s × m × 2e

where s is +1 or -1, m is a positive integer less than 2^53 but not less than 2^52, and e is an integer ranging from -1074 to 971, inclusive.

The remaining 9007199254740990 (that is, 2^53-2) values are denormalized, having the form

s × m × 2e

where s is +1 or -1, m is a positive integer less than 2^52, and e is -1074.

Note that all the positive and negative integers whose magnitude is no greater than 2^53 are representable in the Number type (indeed, the integer 0 has two representations, +0 and -0).

A finite number has an odd significand if it is nonzero and the integer m used to express it (in one of the two forms shown above) is odd. Otherwise, it has an even significand.

译文:18437736874454810622(2^64-2^53-2)个有限的非零值有两种类型:

其中的18428729675200069632(2^64-2^54)个是规范化的,形式是 s × m × 2^e :这里的s是+1或-1代表正负号,m是小于2^53但是不小于2^52的一个正整数,e是一个包括-1074到971之间的整数。

剩下的9007199254740990(2^53-2)个值是非规范的,形式是 s × m × 2^e :这里s是+1或-1代表正负号,m是小于2^52的一个正整数,e是-1074。

注意,所有的正负整数其数量级都是不大于2^53的,并且都是Number类型的(整数0有两种表现,+0和-0)。

一个有限的数字如果它是非0的,并且用于表达的整数m(通过以上两种形式)是奇数则这个数字是具有奇数性质的,反之,是具有偶数性质的(下一段规则会用到这两种性质)。

 

原文:In this specification, the phrase “the Number value for x” where x represents an exact real mathematical quantity (which might even be an irrational number such as π) means a Number value chosen in the following manner. Consider the set of all finite values of the Number type, with -0 removed and with two additional values added to it that are not representable in the Number type, namely 2^1024(which is +1 × 2^53 × 2^971) and -2^1024 (which is -1 × 2^53 × 2^971). Choose the member of this set that is closest in value to x. If two values of the set are equally close, then the one with an even significand is chosen; for this purpose, the two extra values 2^1024 and -2^1024 are considered to have even significands. Finally, if 2^1024 was chosen, replace it with +∞; if -2^1024 was chosen, replace it with -∞; if +0 was chosen, replace it with -0 if and only if x is less than zero; any other chosen value is used unchanged. The result is the Number value for x. (This procedure corresponds exactly to the behaviour of the IEEE 754-2008 “round to nearest, ties to even” mode.)

译文:在规则中,语句"x的数量值"这里的x表示一个准确且实际的数学意义上值(其中甚至包括如π这样的无理数)该值是按照如下的方式来进行选择操作的:考虑所有的Number类型的有限数值集合,去除-0,同时额外添加两个不算在Number类型内的值,即2^1024(1 × 2^53 × 2^971)和-2^1024(-1 × 2^53 × 2^971)。选取集合中最接近x估值的成员作为x的数值,如果集合中有两个同等接近的值,则选择其中具有偶数性质(见上一段翻译)的值;基于这个选择方式,两个额外的值2^1024和-2^1024是被认定为具有偶数性质的值。最后,如果2^1024被选中,则用+∞ 代替,-2^1024被选中,则用 -∞代替;如果+0被选中,当且仅当x小于0时,用-0代替;剩余其他被选中的值都没有特殊变化。这个结果就是x的数量值(这个过程恰好和IEEE754-2008中的“围绕最近,绑定偶数”的方式相一致)。

 

原文:Some ECMAScript operators deal only with integers in specific ranges such as -2^31 through 2^31-1, inclusive, or in the range 0 through2^16-1, inclusive. These operators accept any value of the Number type but first convert each such value to an integer value in the expected range. See the descriptions of the numeric conversion operations in 7.1.

译文:一些ECMAScript的运算操作仅仅基于特殊的整数范围,如包括-2^31到2^31-1,或者包括0到2^16-1。这些运算操作可以接受首先能够被转化成预定范围内整数的任何Number类型的数值。具体参见7.1章。

更多内容,欢迎访问个人网站

  相关解决方案