我试图理解如何数字::toString(x) https://262.ecma-international.org/11.0/#sec-numeric-types-number-tostring抽象操作有效。
据我所知,其要点似乎是非常大(n > 21)和非常小(n
String(1.5e22) // => "1.5+22"
...其他所有内容均以十进制表示法(步骤 6-9)
String(1.5e1) // => "15"
这是第五步:
- Otherwise, let
n
, k
, and s
be integers such that k ≥ 1, 10k - 1 ≤ s < 10k
, the Number value for ℝ(s) × 10ℝℝ(n) - ℝ(k)
is x
, and k
is as small as possible. Note that k
is the number of digits in the decimal representation of s
, that s
is not divisible by 10ℝ
, and that the least significant digit of s
is not necessarily uniquely determined by these criteria.
-
为什么需要步骤 5 中的约束?
Namely, that k
is as small as possible, 10k - 1 ≤ s < 10k
and s
is not divisible by 10ℝ
.
-
的价值观如何n
and k
found?
For the number 1.5e1, the smallest k
for 10k - 1 ≤ s < 10k
and k ≥ 1
to both be true is 2, which would mean n = 2. But this doesn't seem to be correct, since it takes me to step 6 (as k ≤ n ≤ 21
), which doesn't produce the string "15".
-
步骤 6 对应什么用例?
- If
k
≤ n
≤ 21, return the string-concatenation of:
- 的代码单元
k
的十进制表示形式的数字s
(按顺序,没有前导零)
-
n
- k
代码单元 0x0030(数字零)的出现次数
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)