Skip to Content
Navigation:

A stick figure smiling

Here's a preview from my zine, How Integers and Floats Work! If you want to see more comics like this, sign up for my saturday comics newsletter or browse more comics!

Image of a comic. To read the full HTML alt text, click "read the transcript".

browse more comics! get the zine!
read the transcript!

### the (64-bit) floating point number line

Floating point numbers aren’t evenly distributed. Instead, they’re organized into windows: [0.25, 0.5], [0.5, 1], [1,2], [2,4], [4,8], [8,16], all the way up to [2^1023, 2^1024].

Every window has 252 floats in it.

The windows [-2, -1], [-1, -12], [-12, -14], [-14, 0], [0, 14], [14, 12], [12, 1], and [1, 2], each have 2^52 numbers. [2, 4] has 2^52 numbers. [4, 8] has 2^52 numbers.

Illustration of a horizontal line, with the windows plotted out on it, showing that each window doubles in size as it moves away from zero.

the windows go from REALLY small to REALLY big

The window closest to 0 is [2^-1023, 2^-1022]

This is TINY: a hydrogen atom weighs about 2^-76 grams.

The biggest window is [2^1023, 2^1024].

This is HUUUGE: the farthest galaxy we know about is about 2^90 meters away.

the gaps between floats double with every window

window: [1, 2] gap: 2^-52
window: [2, 4] gap: 2^-51
window: [4, 8] gap: 2^-50
window: [8, 16] gap: 2^-49

why does 10000000000000000.0 + 1 = 10000000000000000.0?

  • In the window [2^n, 2^n+1], the gap between floats is 2^n-52
  • 10000000000000000.0 is in the window [2^53, 2^54], where the gap is 2^1 (or 2)
  • So the next float after 10000000000000000.0 is 10000000000000002.0

Saturday Morning Comics!

Want another comic like this in your email every Saturday? Sign up here!

I'll send you one of my favourite comics from my archives every Saturday.
© Julia Evans 2024 | All rights reserved (see the FAQ for notes about licensing)