4-8.htm

来自「浙江大学计算机学院计算机组成教材《计算机组成与设计》(潘学增)的课堂教学课件。」· HTM 代码 · 共 650 行 · 第 1/4 页

HTM
650
字号
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Floating Point 浮点运算</title>
<meta name="Microsoft Theme" content="arcs 001">
</head>

<body background="../images/arctile.jpg" bgcolor="#FFFFFF" text="#000000" link="#3399FF" vlink="#666666" alink="#FF9900">

<h3 align="center"><font color="#000000">&nbsp;<font size="6">4.8 Floating Point 浮点运算</font></font></h3>                                                   
<p align="right"><font color="#000000"><a href="chapter4.htm"><img border="0" src="images/BACK.GIF" width="60" height="45" align="left"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;      
<a href="4-7.htm"><img border="0" src="images/PREV.GIF" width="60" height="45"></a>&nbsp;            
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="../chapter5/index.htm"><img border="0" src="images/FORW.GIF" width="60" height="45"></a></font></p>                                             
<p align="left"><font color="#000000" size="4"><img border="0" src="images/SUB.GIF" width="26" height="27"><a href="#浮点数在机器中的表示形式">浮点数在机器中的表示形式</a><br>                                         
<img border="0" src="images/SUB.GIF" width="26" height="27"><a href="#浮点数的加法">浮点数的加法</a><br>                                         
<img border="0" src="images/SUB.GIF" width="26" height="27"><a href="#浮点数的乘法">浮点数的乘法<br>           
</a><img border="0" src="images/SUB.GIF" width="26" height="27"><a href="#MIPS的浮点指令">MIPS的浮点指令</a><br>                                        
<img border="0" src="images/SUB.GIF" width="26" height="27"><a href="#精度计算">精度计算</a></font></p>                                        
<p align="left"><font color="#000000" size="4">一:<a name="浮点数在机器中的表示形式">浮点数在机器中的表示形式</a></font></p>                                       
<p align="left"><font color="#000000" size="4">1.引言:Speed gets you nowhere if                                                  
you're headed in the wrong direction.--American proverb.</font></p>                                         
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp; 在计算机编程语言中,除了要无符和有符整数之外,还要求有小数,这在实数运算中是很重要的。下面是一些实数的例子:3.14159265...<sub>ten</sub>(pi),2.71828...<sub>ten</sub>(e)                                                
,0.00000000<sub>ten</sub> or 1.0<sub>ten</sub>×10<sup>-9</sup>(seconds in a nanosecond),3155760000<sub>ten</sub> or 3.15576<sub>ten</sub>×10                                             
<sup>9</sup>(seconds ina century)。</font></p>                                         
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp; 注意到最后一个例子中,这个数字并不代表一个小数,但是由于数字太大而不能用一般的有符整数表示,这种表示法称为scientific                                             
notation(科学表示法),这种表示法中十进制小数点的左边只有一位数字。如果小数点左边只有一位数字并且该数字不为零,则该种表示则称为规范化表示。</font></p>                                         
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp; 例如:1.0<sub>ten</sub>×10<sup>-9</sup>是规范化科学数字表示方法,而0.1<sub>ten</sub>×10<sup>-8</sup>和                                           
10.0<sub>ten</sub>×10<sup>-10</sup>就不是。</font></p>                                         
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp; 同十进制表示方法相同,我们可以用科学表示法表示二进制数字。支持这种运算的计算机算术称为浮点运算(floating                                           
point)。在C语言中,float是一种数字类型。同十进制中科学表示法相似,在二进制中,标准的表示方法为:1.xxxxxxxxx<sub>two</sub>×2<sup>yyyy</sup>。</font></p>                                        
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp; 这种对实数的科学表示有三个优点:首先简化了浮点数的数据交换;同时也简化了运算的各种算法;由于去掉了实数的前导的0,提高了有效值位数和数字的精度。</font></p>                                       
<p align="left"><font color="#000000" size="4">2.单精度表示方法:</font></p>                                      
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp; 在MIPS中浮点数的表示如下图:</font></p>                                       
<p align="center"><font color="#000000" size="4"><img border="0" src="images/4-8-pic1.gif" width="530" height="74"></font></p>                                    
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp; 其中,s是浮点数的符号位(1                                        
meaning negative),表示浮点数的正负; exponent是阶码,表示浮点数的最大范围,为指数;significand称为尾数,表示有效位。浮点数表示形式为(-1)<sup>s</sup>×F×2<sup>E</sup>,F为significand的有效值,E为exponent的值。</font></p>                                      
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp; 设计者必须在significand和exponent的数位大小之间找到一个折中固定的方案,因为在算术计算当中操作数的位数必须要首先固定且在相同范围内。这同时也是数字精度和数字表示范围的一个折中,增加significand的大小则提高数字的精度,但增加exponent的大小则增加数字的表示范围,这就是good                                       
design demands compromise.</font></p>                                      
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp;                                       
上图给出的方案中,浮点数的表示范围在2.0<sub>ten</sub>×10<sup>-38</sup>和2.0<sub>ten</sub>×10<sup>38</sup>之间。由于有了范围,则超过此范围的浮点数就不能表示,这样则产生溢出(overflow                                      
interrupts),这同整数是一样的。overflow是由于浮点数太大而不能表示。同样也会有太小而不能表示的浮点数,这时候计算机也会给出一个错误的结果,这种情况称为underflow,也就是exponent中的负指数太大超出了范围。</font></p>                                    
<p align="left"><font color="#000000" size="4">3.双精度表示方法</font></p>                                   
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp; 为了减少overflow和underflow的出现几率,MIPS给出了double                                     
precision floating-point arithmetic,上面的single precision floating-point                                     
arithmetic是单精度浮点运算。这种双精度浮点数的表示范围在2.0<sub>ten</sub>×10<sup>-308</sup>和2.0<sub>ten</sub>×10<sup>308</sup>之间。</font></p>                                   
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp;                                    
一个双精度浮点数需要两个MIPS words,其具体表示如下:</font></p>                                   
<p align="center"><font color="#000000" size="4"><img border="0" src="images/4-8-pic2.gif" width="538" height="110"></font></p>                               
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp; 以上的格式是IEEE                                    
754 floating-point standard的部分标准,这个标准极大的提高了浮点数运算质量和并降低了难度。在IEEE                                    
754标准中,为了更加提高精度,将significand的最前面的1隐藏起来。这样以来单精度中的significand实际上是24                                    
bits长(1 and a 23-bit fraction);双精度中的significand实际上是53 bits长(1+52)。由于0的机器数表示中不是以1为头,则exponent的值为0,硬件不会给significand加1。因此00...00<sub>two</sub>代表0,其他数字则要给significand加1,如公式:(-1)<sup>s</sup>×(1+significand)×2<sup>E</sup>.其中significand是0到1之间的小数,我们用s1,s2,s3,...来表示significand的各位数字,则有公式:<br>                                 
(-1)<sup>s</sup>×(1+(s1×2<sup>-1</sup>)+(s2×2<sup>-2</sup>)+(s3×2<sup>-3</sup>)+...)×2<sup>E</sup>。有了这个公式,我们可以很容易地用整数的处理方法来处理浮点数了,如两数的大小比较,两数是否相等。</font></p>                                
<p align="left"><font color="#000000" size="4">4.偏移表示</font></p>                              
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp;                                 
但是负的阶码在比较大小是碰到了问题,如果我们用一般的方法来表示负数即用补码的形式表示,这样一来,一个负的exponent看起来很像是一个很大的阶码。例如在1.0<sub>two</sub>×2<sup>-1</sup>中,exponent为11111111,而在<br>                               
1.0<sub>two</sub>×2<sup>+1</sup>中,exponent为00000001。我们需要的是最负的exponent应用00...00<sub>two</sub>表示,最正的exponent应用11...11<sub>two</sub>表示。这里我们引入biased                               
notation(偏移值),在IEEE 754中,单精度用127做为偏移值。因此-1用-1+127<sub>ten</sub>即126<sub>ten</sub>=0111 1110<sub>two</sub>来表示,+1用1+127<sub>ten</sub>即128<sub>ten</sub>=1000                              
0000<sub>two</sub>来表示。这样以来,浮点数就用下面这个公式来表示:(-1)<sup>s</sup>×(1+significand)×2<sup>(exponent-bias)</sup>.在单精度中the                              
exponent bias为127,在双精度中the exponent bias为1023。</font></p>                             
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp; 例子:Show the IEEE                              
754 binary representation of the numbers -0.75<sub>ten</sub>                              
in single and double precision.</font></p>                             
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp;                              
在单精度中,一般表示为(-1)<sup>s</sup>×(1+significand)×2<sup>(exponent+127)</sup>.所以-0.75<sub>ten</sub>=(-1)<sup>1</sup>×(1+.1000                              
0000 0000 0000 0000 000<sub>two</sub>)×2<sup>(126)</sup>.其机器数表示如下:</font></p>                            
<p align="center"><font color="#000000" size="4"><img border="0" src="images/4-8-pic3.gif" width="547" height="62"></font></p>                         
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp; 在双精度中,一般表示为(-1)<sup>s</sup>×(1+significand)×2<sup>(exponent+1023)</sup>.所以-0.75<sub>ten</sub>=(-1)<sup>1</sup>×(1+.1000000000000000000000000000000000000000000000000000)×2<sup>(1022)</sup>.其机器数表示如下:</font></p>                            
<p align="center"><font color="#000000" size="4"><img border="0" src="images/4-8-pic4.gif" width="547" height="108"></font></p>                         
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp; 例子:用10进制数表示该机器数。</font></p>                            
<p align="center"><font color="#000000" size="4"><img border="0" src="images/4-8-pic5.gif" width="530" height="74"></font></p>                         
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp; 答案:the sign bit是1,exponent是129,sifnificand是1×2<sup>-2</sup>=1/4                            
or 0.25。因此用(-1)<sup>s</sup>×(1+significand)×2<sup>(exponent-bias)</sup>等式。<br>                           
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (-1)<sup>1</sup>×(1+0.25)×2<sup>(129-127)</sup>=-1×1.25×2<sup>2</sup>=-1.25×4=15.0</font></p>                          
<p align="left"><font color="#000000" size="4">二:<a name="浮点数的加法">浮点数的加法</a></font></p>                         
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp;                          
让我们用一个实例来说明浮点数的加法:9.999<sub>ten</sub>×10<sup>1</sup>+1.610<sub>ten</sub>×10<sup>-1</sup>,假设significand只有4位,exponent只有2位。</font></p>                        
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp;                        
第一步:我们首先对照较大的exponent来调整较小的浮点数,以使两数的exponent大小相同。因此我们<br>                       
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 可以得到1.610<sub>ten</sub>×10<sup>-1</sup>=0.01610<sub>ten</sub>×10<sup>1</sup>,左边的数字是我们想要得到的,两数的exponent大<br>                       
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                        
小相同。但是我们的significand只有4位,因此得到0.016<sub>ten</sub>×10<sup>1</sup>。</font></p>                       
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp;                        
第二步:将两数的sifnificand相加。<br>                       
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                        
9.999<sub>ten</sub><br>                       
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                        
0.016<sub>ten</sub><br>                       
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; +&nbsp;                        
_________<br>                       
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                        
10.015<sub>ten</sub><br>                       
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                        
因此结果为10.015<sub>ten</sub>× 10<sup>1</sup>。</font></p>                       
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp;                        
第三步:规范化上一步得到的结果(normalized)。如:10.015<sub>ten</sub>×10<sup>1</sup>=1.0015<sub>ten</sub>×                        
10<sup>2</sup>。在规范化结果<br>                       
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                        
时要检查结果有没有overflow和underflow,就是要确保exponent仍然在规定范围之内。</font></p>                       
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp;                        
第四步:我们知道significand只有四位长,所以我们必须对数字进行舍入操作。根据四舍五入的原则<br>                       
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ,1.0015<sub>ten</sub>×                        
10<sup>2</sup>在舍入之后得到1.002<sub>ten</sub>× 10<sup>2</sup>。如果结果仍然不规范化,则应该在进行第<br>                       
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                        
三步运算。</font></p>                       
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp;                        
对于单精度数字来说,exponent在127和-126之间;对于双精度数字来说,exponent在1023和-1022之间。在上面第四步中,我们根据IEEE                        
754的浮点数标准来进行舍入操作的。在精度计算中,这则根据所要求的精度而定。</font></p>                       
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp;                       
浮点数加法的具体流程图和硬件设计图如下:</font></p>                      
<p align="center"><font color="#000000" size="4"><img border="0" src="images/4-8-pic6.gif" width="341" height="433"></font></p>                   
<p align="center"><font color="#000000" size="4"><img border="0" src="images/4-8-pic7.gif" width="552" height="406"></font></p>                   
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp; Example: try adding the                        
numbers 0.5<sub>ten</sub> and -0.4375<sub>ten</sub> in binary using above                        
algorithm.<br>                       
&nbsp;&nbsp;&nbsp; Answer:首先将十进制数转化成二进制数,假设要求4位精度。<br>                       
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0.5<sub>ten</sub>=1/2<sub>ten</sub>=1/2<sup>1</sup><sub>ten</sub>=0.1<sub>two</sub>=0.1<sub>two</sub>×2<sup>0</sup>=1.0002<sub>two</sub>×2<sup>-1</sup>=<br>                      
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -0.4375<sub>ten</sub>=-7/16<sub>ten</sub>=-7/2<sup>4</sup><sub>ten</sub>=-0.0111<sub>two</sub>=-0.0111<sub>two</sub>×2<sup>0</sup>=-1.110<sub>two</sub>×2<sup>-2</sup><br>                      
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; step1:-1.110<sub>two</sub>×2<sup>-2</sup>=-0.111<sub>two</sub>×2<sup>-1</sup><br>                      
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; step2:1.0<sub>two</sub>×2<sup>-1</sup>+(-0.111<sub>two</sub>×2<sup>-1)</sup>=0.001<sub>two</sub>×2<sup>-1</sup><br>                      
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; step3:0.001<sub>two</sub>×2<sup>-1</sup>=0.010<sub>two</sub>×2<sup>-2</sup>=0.100<sub>two</sub>×2<sup>-3</sup>=1.000<sub>two</sub>×2<sup>-4</sup>,由于127&gt;=-4&gt;=-126,所以没有产<br>                      
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                       
升overflow和underflow。<br>                      
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; step4:Round the sum:1.000<sub>two</sub>×2<sup>-4</sup>,则最后的结果是1.000<sub>two</sub>×2<sup>-4</sup>=0.0001000<sub>two</sub>=0.0001<sub>two<br>                      
&nbsp;&nbsp;&nbsp;</sub>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                       
=1/2<sup>4</sup><sub>ten</sub>=1/16<sub>ten</sub>=0.0625<sub>ten</sub>。&nbsp;</font></p>                      
<p align="left"><font color="#000000" size="4">三:<a name="浮点数的乘法">浮点数的乘法</a></font></p>                     
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp; 我们用一个例子来说明浮点数乘法的运算方法。</font></p>                    
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp; 例如:1.110<sub>ten</sub>×10<sup>10</sup>×9.200<sub>ten</sub>×10<sup>-5</sup>,同样我们假设sifgificand只有四位,exponent只有两位。&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></p>                     
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp; step1:求阶和,e<sub>sum</sub>=e1+e2-Biase。因为e1=E1+Biase,e2=E2+Biase,e1+e2=E1+E2+Biase+Biase,多加了<br>                    
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 一个Biase,所以要减去一个Biase。<br>                    
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 所以new                     
exponent=(10+127)+(-5+127)-127=259-127=132=(5+127)。<br>                    
&nbsp;&nbsp;&nbsp; step2:尾数相乘,用原码乘较方便。<br>                    
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                    
1.110<sub>ten</sub><br>                   
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                    
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ×&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 9.200<sub>ten</sub><br>                    
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                     
--------<br>                    
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                     
0000<br>                    
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                     
0000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>                    
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                     
2220<br>                    
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                    
&nbsp;&nbsp;&nbsp;&nbsp;                     
9990<br>                    
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                    
&nbsp;&nbsp;                     
------<br>                    
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                    
&nbsp;&nbsp;&nbsp;                     
10212000<sub>ten</sub><br>                    
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                     
我们保留到小数点后边三位,因此可以得到product=10.212×10<sup>5</sup>。</font></p>                   
<p align="left"><font color="#000000" size="4">&nbsp;&nbsp;&nbsp; step3:积进行规范化操作,10.212<sub>ten</sub>×10<sup>5</sup>=1.0212×10<sup>6</sup>。同时还要判断是否产生overflow和underflow<br>                   
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;                   
,如果发生,则产生异常。<br>                  

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?