已閱讀5頁(yè),還剩4頁(yè)未讀, 繼續(xù)免費(fèi)閱讀
版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
幾乎所有計(jì)算機(jī)都支持二進(jìn)制數(shù)據(jù)表示,即能直接識(shí)別二進(jìn)制數(shù)據(jù)表示并具有相應(yīng)的指令系統(tǒng)。通常采用的二進(jìn)制定點(diǎn)數(shù)據(jù)表示主要有:符號(hào)數(shù)值、反碼、補(bǔ)碼以及帶偏移增值碼四種形式,其中最常用的是補(bǔ)碼形式,這些都已在計(jì)算機(jī)組成原理課程中做了詳細(xì)討論,這里不再闡述。 二進(jìn)制浮點(diǎn)數(shù)的表示,由于不同機(jī)器所選的基值、尾數(shù)位長(zhǎng)度和階碼位長(zhǎng)度不同,因此對(duì)浮點(diǎn)數(shù)表示有較大差別,這就不利于軟件在不同計(jì)算機(jī)間的移植。美國(guó)IEEE(電子及電子工程師協(xié)會(huì))為此提出了一個(gè)從系統(tǒng)結(jié)構(gòu)角度支持浮點(diǎn)數(shù)的表示方法, 稱(chēng)之為IEEE標(biāo)準(zhǔn)754(IEEE,1985),當(dāng)今流行的計(jì)算機(jī)幾乎都采用這一標(biāo)準(zhǔn)。 IEEE 754在標(biāo)識(shí)符點(diǎn)數(shù)時(shí), 每個(gè)浮點(diǎn)數(shù)均由3個(gè)部分組成:符號(hào)位S,指數(shù)部分E和尾數(shù)部分M。 浮點(diǎn)數(shù)可采用以下四種基本格式: (1)單精度格式(32位):E=8位,M=23位。 (2)擴(kuò)展單精度格式:E11位,M31位。 (3)雙精度格式(64)位:E=11位,M=52位。 (4)擴(kuò)展雙精度格式(64位):E15位,M63位。 其中,單精度格式(32位)中的階碼為8位, 另有一位尾數(shù)的符號(hào)位S,處在最高位。如圖4.2.1所示。應(yīng)該指出的是,浮點(diǎn)數(shù)的分?jǐn)?shù)部分與有效位部分兩者是不同的, 由于IEEE754標(biāo)準(zhǔn)約定在小數(shù)點(diǎn)左部有一位隱含位,從而使其有效位實(shí)際有24位,這樣便使尾數(shù)的有效值變?yōu)?M。階碼部分采用移碼表示, 移碼值為127,從而使階碼值的范圍由原來(lái)的1到254,經(jīng)移碼后變?yōu)?126到+127。 IEEE 754標(biāo)準(zhǔn)的單精度和雙精度浮點(diǎn)數(shù)表示格式。其中,階碼值0和255分別用來(lái)表示特殊數(shù)值:當(dāng)階碼值為255時(shí),若分?jǐn)?shù)部分為0,則表示無(wú)窮大;若分?jǐn)?shù)部分不為0,則認(rèn)為這是一個(gè)非數(shù)值。當(dāng)階碼和尾數(shù)均為0時(shí)則表示該數(shù)值為0,因?yàn)榉橇銛?shù)的有效位總是1,因此特別約定,這表示為0。當(dāng)階碼為0, 尾數(shù)不為0時(shí),該數(shù)絕對(duì)值較小, 允許采用比最小規(guī)格化數(shù)還要小的數(shù)表示。概括起來(lái),由32位單精度所表示的IEEE 754標(biāo)準(zhǔn)浮點(diǎn)數(shù)N可以有如下的解釋?zhuān)?若E=0,且M=0,則N為0。 若E=0,且M0,則N=(-1)S2-126(0.M)。為非規(guī)格化數(shù)。 若1E254,則N=(-1)S2E-127(1.M)。為規(guī)格化數(shù)。 若E=255,且M0,則N=NaN(非數(shù)值)。 若E=255,且M=0,則N=(-1)S(無(wú)窮大)。 由此可見(jiàn), IEEE 754標(biāo)準(zhǔn)使0有了精確表示,同時(shí)也明確地表示了無(wú)窮大,所以,當(dāng)a/0(a0)時(shí)得到結(jié)果值為;當(dāng)0/0時(shí)得到結(jié)果值較小的數(shù),為了避免下溢而損失精度,允許采用比最小規(guī)格化數(shù)還要小的數(shù)來(lái)表示,這些數(shù)稱(chēng)為非規(guī)格化數(shù)(Denormalnumber)。應(yīng)注意的是,非規(guī)格化數(shù)和正、負(fù)零的隱含位值不是1而是0。 下面舉兩個(gè)例子來(lái)說(shuō)明IEEE 754標(biāo)準(zhǔn)浮點(diǎn)數(shù)的表示: (1)N=-1.5,它的單精度格式表示為: 1 01111111 10000000000000000000000 其中,S=1,E=127,M=0.5,因此N=-1.5。 (2)以下的32位數(shù)所表示的單精度浮點(diǎn)數(shù)為多少? 1 10000001 01000000000000000000000 其中,S=1,E=129,M=0.25,由公式可知N=-5。 IEEE Standard 754 floating point is the most common representation today for real numbers on computers, including Intel-based PCs, Macintoshes, and most Unix platforms. This article gives a brief overview of IEEE floating point and its representation. Discussion of arithmetic implementation may be found in the book mentioned at the bottom of this article.What Are Floating Point Numbers?There are several ways to represent real numbers on computers. Fixed point places a radix point somewhere in the middle of the digits, and is equivalent to using integers that represent portions of some unit. For example, one might represent 1/100ths of a unit; if you have four decimal digits, you could represent 10.82, or 00.01. Another approach is to use rationals, and represent every number as the ratio of two integers.Floating-point representation - the most common solution - basically represents reals in scientific notation. Scientific notation represents numbers as a base number and an exponent. For example, 123.456 could be represented as 1.23456 x 102. In hexadecimal, the number 123.abc might be represented as 1.23abc x 162.Floating-point solves a number of representation problems. Fixed-point has a fixed window of representation, which limits it from representing very large or very small numbers. Also, fixed-point is prone to a loss of precision when two large numbers are divided.Floating-point, on the other hand, employs a sort of sliding window of precision appropriate to the scale of the number. This allows it to represent numbers from 1,000,000,000,000 to 0.0000000000000001 with ease.Storage LayoutIEEE floating point numbers have three basic components: the sign, the exponent, and the mantissa. The mantissa is composed of the fraction and an implicit leading digit (explained below). The exponent base (2) is implicit and need not be stored.The following figure shows the layout for single (32-bit) and double (64-bit) precision floating-point values. The number of bits for each field are shown (bit ranges are in square brackets):SignExponentFractionBiasSingle Precision1 318 30-2323 22-00127Double Precision1 6311 62-5252 51-001023The Sign BitThe sign bit is as simple as it gets. 0 denotes a positive number; 1 denotes a negative number. Flipping the value of this bit flips the sign of the number.The ExponentThe exponent field needs to represent both positive and negative exponents. To do this, a bias is added to the actual exponent in order to get the stored exponent. For IEEE single-precision floats, this value is 127. Thus, an exponent of zero means that 127 is stored in the exponent field. A stored value of 200 indicates an exponent of (200-127), or 73. For reasons discussed later, exponents of -127 (all 0s) and +128 (all 1s) are reserved for special numbers.For double precision, the exponent field is 11 bits, and has a bias of 1023.The MantissaThe mantissa, also known as the significand, represents the precision bits of the number. It is composed of an implicit leading bit and the fraction bits.To find out the value of the implicit leading bit, consider that any number can be expressed in scientific notation in many different ways. For example, the number five can be represented as any of these: 5.00 x 100 0.05 x 102 5000 x 10-3In order to maximize the quantity of representable numbers, floating-point numbers are typically stored in normalized form. This basically puts the radix point after the first non-zero digit. In normalized form, five is represented as 5.0 x 100.A nice little optimization is available to us in base two, since the only possible non-zero digit is 1. Thus, we can just assume a leading digit of 1, and dont need to represent it explicitly. As a result, the mantissa has effectively 24 bits of resolution, by way of 23 fraction bits.Putting it All TogetherSo, to sum up:1 The sign bit is 0 for positive, 1 for negative.2 The exponents base is two.3 The exponent field contains 127 plus the true exponent for single-precision, or 1023 plus the true exponent for double precision.4 The first bit of the mantissa is typically assumed to be 1.f, where f is the field of fraction bits.Ranges of Floating-Point NumbersLets consider single-precision floats for a second. Note that were taking essentially a 32-bit number and re-jiggering the fields to cover a much broader range. Something has to give, and its precision. For example, regular 32-bit integers, with all precision centered around zero, can precisely store integers with 32-bits of resolution. Single-precision floating-point, on the other hand, is unable to match this resolution with its 24 bits. It does, however, approximate this value by effectively truncating from the lower end. For example: 11110000 11001100 10101010 00001111 / 32-bit integer = +1.1110000 11001100 10101010 x 231 / Single-Precision Float = 11110000 11001100 10101010 00000000 / Corresponding ValueThis approximates the 32-bit value, but doesnt yield an exact representation. On the other hand, besides the ability to represent fractional components (which integers lack completely), the floating-point value can represent numbers around 2127, compared to 32-bit integers maximum value around 232.The range of positive floating point numbers can be split into normalized numbers (which preserve the full precision of the mantissa), and denormalized numbers (discussed later) which use only a portion of the fractionss precision.DenormalizedNormalizedApproximate DecimalSingle Precision 2-149 to (1-2-23)x2-126 2-126 to (2-2-23)x2127 10-44.85 to 1038.53Double Precision 2-1074 to (1-2-52)x2-1022 2-1022 to (2-2-52)x21023 10-323.3 to 10308.3Since the sign of floating point numbers is given by a special leading bit, the range for negative numbers is given by the negation of the above values.There are five distinct numerical ranges that single-precision floating-point numbers are not able to represent:5 Negative numbers less than -(2-2-23) x 2127 (negative overflow)6 Negative numbers greater than -2-149 (negative underflow)7 Zero8 Positive numbers less than 2-149 (positive underflow)9 Positive numbers greater than (2-2-23) x 2127 (positive overflow)Overflow means that values have grown too large for the representation, much in the same way that you can overflow integers. Underflow is a less serious problem because is just denotes a loss of precision, which is guaranteed to be closedly approximated by zero.Heres a table of the effective range (excluding infinite values) of IEEE floating-point numbers:BinaryDecimalSingle (2-2-23)127 1038.53Double (2-2-52)1023 10308.25Note that the extreme values occur (regardless of sign) when the exponent is at the maximum value for finite numbers (2127 for single-precision, 21023 for double), and the mantissa is filled with 1s (including the normalizing 1 bit).Special ValuesIEEE reserves exponent field values of all 0s and all 1s to denote special values in the floating-point scheme.ZeroAs mentioned above, zero is not directly representable in the straight format, due to the assumption of a leading 1 (wed need to specify a true zero mantissa to yield a value of zero). Zero is a special value denoted with an exponent field of zero and a fraction field of zero. Note that -0 and +0 are distinct values, though they both compare as equal.DenormalizedIf the exponent is all 0s, but the fraction is non-zero (else it would be interpreted as zero), then the value is a denormalized number, which does not have an assumed leading 1 before the binary point. Thus, this represents a number (-1)s x 0.f x 2-126, where s is the sign bit and f is the fraction. For double precision, denormalized numbers are of the form (-1)s x 0.f x 2-1022. From this you can interpret zero as a special type of denormalized number.InfinityThe values +infinity and -infinity are denoted with an exponent of all 1s and a fraction of all 0s. The sign bit distinguishes between negative infinity and positive infinity. Being able to denote infinity as a specific value is useful because it allows operations to continue past overflow situations. Operations with infinite values are well defined in IEEE floating point.Not A NumberThe value NaN (Not a Number) is used to represent a value that does not represent a real number. NaNs are represented by a bit pattern with an exponent of all 1s and a non-zero fraction. There are two categories of NaN: QNaN (Quiet NaN) and SNaN (Signalling NaN).A QNaN is a NaN with the most significant fraction bit set. QNaNs propagate freely through most arithmetic operations. These values pop out of an operation when the result is not mathematically defined.An SNaN is a NaN with the most significant fraction bit clear. It is used to signal an exception when used in operations. SNaNs can be handy to assign to uninitialized variables to trap premature usage.Semantically, QNaNs denote indeterminate operations, while SNaNs denote invalid operations.Special OperationsOperations on special numbers are well-defined by IEEE. In the simplest case, any operation with a NaN yields a NaN result. Other operations are as follows:OperationResultn / Infinity0Infinity x InfinityInfinitynonzero / 0InfinityInfinity + InfinityInfinity0 / 0NaNInfinity - InfinityNaNInfinity / InfinityNaNInfinity x 0NaNSummaryTo sum up, the following are the corresponding values for a given representation:Float Values (b = bias)SignExponent (e)Fraction (f)Value000.0000.00+0000.0000.01:11.11Positive Denormalized Re
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年浙江貨運(yùn)從業(yè)資格證模擬
- 2025年成都b2貨運(yùn)資格證多少道題
- 加入學(xué)生會(huì)的演講稿15篇
- 2025個(gè)人股權(quán)轉(zhuǎn)讓協(xié)議書(shū)范本及法律風(fēng)險(xiǎn)提示2篇
- 2025年度文化產(chǎn)業(yè)發(fā)展專(zhuān)項(xiàng)資金使用及監(jiān)管合同4篇
- 2025年度新材料研發(fā)場(chǎng)委托招聘協(xié)議3篇
- 2025年度信息技術(shù)項(xiàng)目臨時(shí)工雇傭合同范本3篇
- 二零二五年度土地租賃合同法律風(fēng)險(xiǎn)防控協(xié)議
- 2025年度UPS不間斷電源設(shè)備銷(xiāo)售與產(chǎn)品研發(fā)合作合同3篇
- 二零二五年度嬰幼兒奶粉品牌授權(quán)專(zhuān)賣(mài)店加盟合同協(xié)議書(shū)
- 2025年安慶港華燃?xì)庀薰菊衅腹ぷ魅藛T14人高頻重點(diǎn)提升(共500題)附帶答案詳解
- 人教版(2025新版)七年級(jí)下冊(cè)數(shù)學(xué)第七章 相交線與平行線 單元測(cè)試卷(含答案)
- GB/T 44351-2024退化林修復(fù)技術(shù)規(guī)程
- 完整2024年開(kāi)工第一課課件
- 從跨文化交際的角度解析中西方酒文化(合集5篇)xiexiebang.com
- 中藥飲片培訓(xùn)課件
- 醫(yī)院護(hù)理培訓(xùn)課件:《早產(chǎn)兒姿勢(shì)管理與擺位》
- 《論文的寫(xiě)作技巧》課件
- 空氣自動(dòng)站儀器運(yùn)營(yíng)維護(hù)項(xiàng)目操作說(shuō)明以及簡(jiǎn)單故障處理
- 2022年12月Python-一級(jí)等級(jí)考試真題(附答案-解析)
- T-CHSA 020-2023 上頜骨缺損手術(shù)功能修復(fù)重建的專(zhuān)家共識(shí)
評(píng)論
0/150
提交評(píng)論