Floating-point numbers can be hazardous. In this chapter, we take a look at some of the pitfalls of floating-point computation and develop rules of thumb through which we can (hopefully) avoid most of them. We first examine some of the catastrophic and even deadly consequences of using floating-point computation poorly. We then bring things down a bit and examine expressions and processes that can lead to a loss of precision. Next, we enumerate some rules of thumb that can help us design code that is less susceptible to these pitfalls, thereby leading to more robust software. Finally, we describe a software tool that can help refactor floating-point code to be more reliable.

错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

Pitfalls of Floating-Point Numbers (And How To Avoid Them)

  • Ronald T. Kneusel

摘要

Floating-point numbers can be hazardous. In this chapter, we take a look at some of the pitfalls of floating-point computation and develop rules of thumb through which we can (hopefully) avoid most of them. We first examine some of the catastrophic and even deadly consequences of using floating-point computation poorly. We then bring things down a bit and examine expressions and processes that can lead to a loss of precision. Next, we enumerate some rules of thumb that can help us design code that is less susceptible to these pitfalls, thereby leading to more robust software. Finally, we describe a software tool that can help refactor floating-point code to be more reliable.