網路城邦
回本城市首頁 STORY OF CITY
市長:Story Sharing  副市長:
加入本城市推薦本城市加入我的最愛訂閱最新文章
udn城市不分類不分類【STORY OF CITY】城市/討論區/
討論區不分版 字體:
上一個討論主題 回文章列表 下一個討論主題
Floating-Point Math
 瀏覽576|回應0推薦0

crazyinformation
等級:3
留言加入好友

Builders of computer systems often need information about floating-point arithmetic. There are, however, remarkably few sources of detailed information about it. One of the few books on the subject, Floating-Point Computation by Pat Sterbenz, is long out of print. This paper is a tutorial on those aspects of floating-point arithmetic (floating-point hereafter) that have a direct connection to systems building. It consists of three loosely connected parts. The first Section, "Rounding Error," on page 173, discusses the implications of using different rounding strategies for the basic operations of addition, subtraction, multiplication and division. It also contains background information on the two methods of measuring rounding error, ulps and relative error. The second part discuses the IEEE floating-point standard, which is becoming rapidly accepted by commercial hardware manufacturers. Included in the IEEE standard is the rounding method for basic operations. The discussion of the standard draws on the material in the Section , "Rounding Error," on page 173. The third part discusses the onnections between floating-point and the design of various aspects of computer systems. Topics include instruction set design, optimizing compilers and exception handling.





I have tried to avoid making statements about floating-point without also giving reasons why the statements are true, especially since the justifications involve nothing more complicated than elementary calculus. Those explanations that are not central to the main argument have been grouped into a section called "The Details," so that they can be skipped if desired. In particular, the proofs of many of the theorems appear in this section. The end of each proof is marked with the * symbol; when a proof is not included, the * appears immediately following the statement of the theorem.





Squeezing infinitely many real numbers into a finite number of bits requires an approximate representation. Although there are infinitely many integers, in most programs the result of integer computations can be stored in 32 bits. In contrast, given any fixed number of bits, most calculations with real numbers will produce quantities that cannot be exactly represented using that many bits. Therefore the result of a floating-point calculation must often be rounded in order to fit back into its finite representation. This rounding error is the characteristic feature of floating-point computation. "Relative Error and Ulps" on page 176 describes how it is measured.





Since most floating-point calculations have rounding error anyway, does it matter if the basic arithmetic operations introduce a little bit more rounding error than necessary? That question is a main theme throughout this section. "Guard Digits" on page 178 discusses guard digits, a means of reducing the error when subtracting two nearby numbers. Guard digits were considered sufficiently important by IBM that in 1968 it added a guard digit to the double precision format in the System/360 architecture (single precision already had a guard digit), and retrofitted all existing machines in the field. Two examples are given to illustrate the utility of guard digits.





The IEEE standard goes further than just requiring the use of a guard digit. It gives an algorithm for addition, subtraction, multiplication, division and square root, and requires that implementations produce the same result as that algorithm. Thus, when a program is moved from one machine to another, the results of the basic operations will be the same in every bit if both machines support the IEEE standard. This greatly simplifies the porting of programs. Other uses of this precise specification are given in "Exactly Rounded Operations" on page 185.





"You are Israel's teacher," said Jesus, "and do you not understand these things? I tell you the truth, we speak of what we know, and we testify to what we have seen, but still you people do not accept our testimony. I have spoken to you of earthly things and you do not believe; how then will you believe if I speak of heavenly things? No one has ever gone into heaven except the one who came from heaven—the Son of Man. Just as Moses lifted up the snake in the desert, so the Son of Man must be lifted up, that everyone who believes in him may have eternal life. "For God so loved the world that he gave his one and only Son, that whoever believes in him shall not perish but have eternal life. For God did not send his Son into the world to condemn the world, but to save the world through him. Whoever believes in him is not condemned, but whoever does not believe stands condemned already because he has not believed in the name of God's one and only Son. This is the verdict: Light has come into the world, but men loved darkness instead of light because their deeds were evil. Everyone who does evil hates the light, and will not come into the light for fear that his deeds will be exposed. But whoever lives by the truth comes into the light, so that it may be seen plainly that what he has done has been done through God."





Many of us have come to understand that it is the powers of nature rather than spooks in the sky that drives all species to compete for survival, and realize that we must devise ways to overcome the need to compete for the earthly resources that sustain our livelihood. We now have the transportation and communication technology to govern the planet with a single administration, and could prevent the costs and sorrows of war by uniting the nations. Then we would no longer need large populations to supply us with plentiful cannon fodder, or the modern technical weaponry to defeat each other with. By eliminating the need for trade and immigration restrictions we could save still more. By offering such huge savings to the public we should, in effect, be able to bribe the masses into abandoning their attempts to gain legislated advantages over each other. By so doing, we could additionally save the enormous expense of holding periodic elections, and the high salaries and perks of the representatives that gain their support through providing the majorities with legislation that economically appeases them: ridding ourselves of the scoundrels that lead us to commit such atrocities upon each other.





Without politicians and governmental programs for the unemployable, we would have to revert back to the times where family groups cared for their own invalids and elders, and with the tax money retained, could again provide assistance or disability insurance for the truly needy. This would prevent the present welfare scams, and second generations that become accustomed to living on the dole: for relatives wouldn't continue to slave for those that were inconsiderate of them. People should be more concerned with the able bodied, and strive to prevent further deterioration of the planet's life supporting environment. As well we must use our advancing intelligence to overcome our need to compete, rather than by using our animalistic instincts to compete to the best of our ability. Avoiding remaining our own worst enemy, and providing ourselves with an environment where we are able to respect each others equality through taking the initiative to use our advancing wisdom and abilities to guide our civilization to its highest potential for all time. However, don't vote for me, I'm only trying to tell you how you should run the whole shebang. It is you that must learn to lead yourselves: rather than be led to an untimely end, like a herd of sheep. Probably we should arrange to have weekly gatherings and use modern communication devises as we do in the present, to convert us from our present national, political, and religious conflictions, to bring us to the bountifulness that a species that is one of mind and purpose can provide for itself.





If I speak in the tongues of men and of angels, but have not love, I am only a resounding gong or a clanging cymbal. If I have the gift of prophecy and can fathom all mysteries and all knowledge, and if I have a faith that can move mountains, but have not love, I am nothing. If I give all I possess to the poor and surrender my body to the flames, but have not love, I gain nothing. Love is patient, love is kind. It does not envy, it does not boast, it is not proud. It is not rude, it is not self-seeking, it is not easily angered, it keeps no record of wrongs. Love does not delight in evil but rejoices with the truth. It always protects, always trusts, always hopes, always perseveres. Love never fails. But where there are prophecies, they will cease; where there are tongues, they will be stilled; where there is knowledge, it will pass away. For we know in part and we prophesy in part, but when perfection comes, the imperfect disappears. When I was a child, I talked like a child, I thought like a child, I reasoned like a child. When I became a man, I put childish ways behind me. Now we see but a poor reflection as in a mirror; then we shall see face to face. Now I know in part; then I shall know fully, even as I am fully known. And now these three remain: faith, hope and love. But the greatest of these is love.





If I speak in the tongues of men and of angels, but have not love, I am only a resounding gong or a clanging cymbal. If I have the gift of prophecy and can fathom all mysteries and all knowledge, and if I have a faith that can move mountains, but have not love, I am nothing. If I give all I possess to the poor and surrender my body to the flames, but have not love, I gain nothing. Love is patient, love is kind. It does not envy, it does not boast, it is not proud. It is not rude, it is not self-seeking, it is not easily angered, it keeps no record of wrongs. Love does not delight in evil but rejoices with the truth. It always protects, always trusts, always hopes, always perseveres. Love never fails. But where there are prophecies, they will cease; where there are tongues, they will be stilled; where there is knowledge, it will pass away. For we know in part and we prophesy in part, but when perfection comes, the imperfect disappears. When I was a child, I talked like a child, I thought like a child, I reasoned like a child. When I became a man, I put childish ways behind me. Now we see but a poor reflection as in a mirror; then we shall see face to face. Now I know in part; then I shall know fully, even as I am fully known. And now these three remain: faith, hope and love. But the greatest of these is love.

回應 回應給此人 推薦文章 列印 加入我的文摘

引用
引用網址:https://city.udn.com/forum/trackback.jsp?no=62823&aid=3417243