mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-29 21:33:07 +08:00
deploy
This commit is contained in:
@ -1880,10 +1880,10 @@
|
||||
<ol>
|
||||
<li>整数类型 int 占用 4 bytes = 32 bits ,可以表示 <span class="arithmatex">\(2^{32}\)</span> 个不同的数字;</li>
|
||||
<li>将最高位视为符号位,<span class="arithmatex">\(0\)</span> 代表正数,<span class="arithmatex">\(1\)</span> 代表负数,一共可表示 <span class="arithmatex">\(2^{31}\)</span> 个正数和 <span class="arithmatex">\(2^{31}\)</span> 个负数;</li>
|
||||
<li>当所有 bits 为 0 时代表数字 <span class="arithmatex">\(0\)</span> ,从零开始增大,可得最大正数为 <span class="arithmatex">\(2^{31} - 1\)</span>;</li>
|
||||
<li>当所有 bits 为 0 时代表数字 <span class="arithmatex">\(0\)</span> ,从零开始增大,可得最大正数为 <span class="arithmatex">\(2^{31} - 1\)</span> ;</li>
|
||||
<li>剩余 <span class="arithmatex">\(2^{31}\)</span> 个数字全部用来表示负数,因此最小负数为 <span class="arithmatex">\(-2^{31}\)</span> ;具体细节涉及“源码、反码、补码”的相关知识,有兴趣的同学可以查阅学习;</li>
|
||||
</ol>
|
||||
<p>其它整数类型 byte, short, long 的取值范围的计算方法与 int 类似,在此不再赘述。</p>
|
||||
<p>其他整数类型 byte, short, long 的取值范围的计算方法与 int 类似,在此不再赘述。</p>
|
||||
<h3 id="_2">浮点数表示方式 *<a class="headerlink" href="#_2" title="Permanent link">¶</a></h3>
|
||||
<div class="admonition note">
|
||||
<p class="admonition-title">Note</p>
|
||||
@ -1896,7 +1896,7 @@
|
||||
<li>指数位 <span class="arithmatex">\(\mathrm{E}\)</span> :占 8 bits ;</li>
|
||||
<li>分数位 <span class="arithmatex">\(\mathrm{N}\)</span> :占 24 bits ,其中 23 位显式存储;</li>
|
||||
</ul>
|
||||
<p>设 32-bit 二进制数的第 <span class="arithmatex">\(i\)</span> 位为 <span class="arithmatex">\(b_i\)</span>,则 float 值的计算方法定义为:</p>
|
||||
<p>设 32-bit 二进制数的第 <span class="arithmatex">\(i\)</span> 位为 <span class="arithmatex">\(b_i\)</span> ,则 float 值的计算方法定义为:</p>
|
||||
<div class="arithmatex">\[
|
||||
\text { val } = (-1)^{b_{31}} \times 2^{\left(b_{30} b_{29} \ldots b_{23}\right)_2-127} \times\left(1 . b_{22} b_{21} \ldots b_0\right)_2
|
||||
\]</div>
|
||||
|
Reference in New Issue
Block a user