O'Reilly logo

Bebop to the Boolean Boogie, 3rd Edition by Clive Maxfield

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix H. Rounding Algorithms 101

Introduction

We all remember being taught the concept of rounding in our younger years at school. Common problems involved monetary values, such as rounding some amount like $26.19 to the nearest dollar (which would be 26 dollars, in the case of this example). However, although this may seem simple at a first glance, there’s a lot more to rounding than might at first meet the eye …

One key aspect of rounding that is easy to overlook (because it’s so obvious) is that it involves transforming some quantity from a greater precision to a lesser precision. As we’ve just seen, for example, rounding a more precise value like $26.19 to the nearest dollar results in 26 dollars, which is less precise.

This means that ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required