Skip to content
Tech News
← Back to articles

Exposing Floating Point – Bartosz Ciechanowski (2019)

read original more articles
Why This Matters

This article demystifies the complexities of floating point numbers, specifically IEEE 754 format, making it more accessible for developers and consumers alike. Understanding floating point behavior is crucial for accurate numerical computations and avoiding unexpected errors in software systems. The insights provided help improve precision management and debugging in various tech applications.

Key Takeaways

Despite everyday use, floating point numbers are often understood in a hand-wavy manner and their behavior raises many eyebrows. Over the course of this article I’d like to show that things aren’t actually that complicated.

This blog post is a companion to my recently launched website – float.exposed. Other than exploiting the absurdity of present day list of top level domains, it’s intended to be a handy tool for inspecting floating point numbers. While I encourage you to play with it, the purpose of many of its elements may be exotic at first. By the time we’ve finished, however, all of them will hopefully become familiar.

On a technical note, by floating point I’m referring to the ubiquitous IEEE 754 binary floating point format. Types half , float , and double are understood to be binary16, binary32, and binary64 respectively. There were other formats back in the day, but whatever device you’re reading this on is pretty much guaranteed to use IEEE 754.

With the formalities out of the way, let’s start at the shallow end of the pool.

Writing Numbers

We’ll begin with the very basics of writing numeric values. The initial steps may seem trivial, but starting from the first principles will help us build a working model of floating point numbers.

Decimal Numbers

Consider the number 327.849. Digits to the left of the decimal point represent increasing powers of ten, while digits to the right of the decimal point represent decreasing powers of ten:

3 102 2 101 7 100 . 8 10−1 4 10−2 9 10−3

Even though this notation is very natural, it has a few disadvantages:

... continue reading